openapi: 3.1.0
info:
  title: CSNB Vehicle Data API
  version: 1.0.0
  description: |
    Vehicle registration and VIN lookups with a unified JSON schema.
    Australia is live; the United States lane is in development.
servers:
  - url: https://api.csnb.net
tags:
  - name: rapidapi
    description: RapidAPI-gateway-compatible legacy endpoint
  - name: agent
    description: AI-agent lanes (MCP + pay-per-call)
paths:
  /vehiclecheck/sure/query:
    get:
      tags: [rapidapi]
      summary: Vehicle lookup (legacy RapidAPI contract)
      description: Drop-in compatible with the AU Rego Check backend.
      security:
        - RapidApiProxySecret: []
      parameters:
        - name: regoOrVin
          in: query
          required: true
          schema: { type: string }
          description: Registration plate or 17-character VIN.
        - name: state
          in: query
          required: true
          schema: { type: string }
          description: Australian state/territory code or full name.
      responses:
        "200":
          description: Vehicle record (see VehicleResult).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/VehicleResult" }
    post:
      tags: [rapidapi]
      summary: Vehicle lookup (form or JSON body)
      security:
        - RapidApiProxySecret: []
      responses:
        "200":
          description: Vehicle record (see VehicleResult).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/VehicleResult" }
  /mcp:
    post:
      tags: [agent]
      summary: MCP server (streamable HTTP, JSON-RPC)
      description: |
        Model Context Protocol endpoint. Tools: vehicle_lookup, coverage.
        Authenticate with `Authorization: Bearer <api-key>`.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [jsonrpc, method]
              properties:
                jsonrpc: { type: string, const: "2.0" }
                id: {}
                method: { type: string }
                params: { type: object }
      responses:
        "200": { description: JSON-RPC result or error }
        "401": { description: Missing/invalid API key }
  /agent/check:
    get:
      tags: [agent]
      summary: Pay-per-call agent lookup (x402, USDC on Base)
      parameters:
        - name: country
          in: query
          required: true
          schema: { type: string, default: AU }
        - name: plate
          in: query
          required: true
          schema: { type: string }
        - name: state
          in: query
          required: false
          schema: { type: string }
      responses:
        "200":
          description: Paid lookup result.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/VehicleResult" }
        "402":
          description: Payment required (x402 invoice details in body).
  /health:
    get:
      summary: Liveness probe
      responses:
        "200": { description: ok }
components:
  securitySchemes:
    RapidApiProxySecret:
      type: apiKey
      in: header
      name: X-RapidAPI-Proxy-Secret
    BearerAuth:
      type: http
      scheme: bearer
  schemas:
    VehicleResult:
      type: object
      properties:
        search: { type: [string, "null"] }
        state: { type: [string, "null"] }
        year: { type: [string, "null"] }
        make: { type: [string, "null"] }
        model: { type: [string, "null"] }
        vin: { type: [string, "null"] }
        body: { type: [string, "null"] }
        transmission: { type: [string, "null"] }
        description: { type: [string, "null"] }
        nvic: { type: [string, "null"] }
        vehicleValueMin: { type: [number, "null"] }
        vehicleValueMax: { type: [number, "null"] }
        vehicleMinMarketValue: { type: [number, "null"] }
        _meta:
          type: object
          properties:
            source: { type: string }
            reason: { type: string }
            confidence: { type: string }
