{
  "openapi": "3.1.0",
  "info": {
    "title": "LMX Labs Lookup API",
    "version": "1",
    "summary": "Check an x402 endpoint before an agent pays it.",
    "description": "Free and keyless. Returns the strongest evidence LMX Labs has for an endpoint: a Level 1 paid correctness check when one is on file, otherwise a Level 0 unpaid check of its 402 payment request compared with its directory listing. A first look at an unknown endpoint runs one unpaid request; nothing is ever paid by a lookup.",
    "contact": {
      "name": "LMX Labs",
      "url": "https://lmxlabs.app",
      "email": "support@lmxlabs.app"
    }
  },
  "externalDocs": {
    "url": "https://lmxlabs.app/docs/lookup-api"
  },
  "servers": [
    {
      "url": "https://lmxlabs.app"
    }
  ],
  "paths": {
    "/api/lookup": {
      "get": {
        "operationId": "lookupEndpoint",
        "summary": "Look up an x402 endpoint",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "description": "The endpoint URL (public https).",
            "schema": {
              "type": "string",
              "format": "uri"
            }
          },
          {
            "name": "x-lmx-client",
            "in": "header",
            "required": false,
            "description": "Optional client label.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Evidence for the endpoint",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LookupResponse"
                }
              }
            }
          },
          "400": {
            "description": "Not a public https endpoint URL",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LookupResponse"
                }
              }
            }
          },
          "429": {
            "description": "Too many new first-look lookups from this caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LookupResponse"
                }
              }
            }
          },
          "503": {
            "description": "Lookup is not configured"
          }
        }
      },
      "post": {
        "operationId": "requestPaidCheck",
        "summary": "Ask Labs to run a paid correctness check on an endpoint",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "contact": {
                    "type": "string",
                    "maxLength": 200,
                    "description": "Optional email or handle for the result."
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Request recorded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "const": true
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "const": false
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "LookupResponse": {
        "type": "object",
        "required": [
          "schema",
          "query",
          "kind",
          "level",
          "label"
        ],
        "properties": {
          "schema": {
            "const": "lmx.lookup/1"
          },
          "query": {
            "type": "string"
          },
          "url": {
            "type": [
              "string",
              "null"
            ]
          },
          "host": {
            "type": [
              "string",
              "null"
            ]
          },
          "kind": {
            "enum": [
              "paid",
              "paid_private",
              "health",
              "first_look",
              "invalid",
              "rate_limited"
            ],
            "description": "paid: a public Level 1 record. paid_private: a paid check exists but the seller isn't named. health: Level 0 history. first_look: Level 0 run just now. "
          },
          "level": {
            "enum": [
              1,
              0,
              null
            ]
          },
          "label": {
            "type": "string"
          },
          "checked_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "paid_check": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "verdict": {
                "type": "string"
              },
              "record_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "record_url": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Public record anyone can verify at /verify."
              },
              "checked_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "checks": {
                "type": "integer"
              },
              "self_test": {
                "type": "boolean"
              },
              "private": {
                "type": "boolean"
              },
              "notified": {
                "type": "boolean"
              }
            }
          },
          "health": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "method": {
                "type": "string"
              },
              "url": {
                "type": "string"
              },
              "status": {
                "enum": [
                  "up",
                  "down",
                  "not_x402",
                  "broken_402",
                  "gone",
                  "rejected",
                  "rate_limited"
                ]
              },
              "http_status": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "checked_at": {
                "type": "string",
                "format": "date-time"
              },
              "paywall": {
                "enum": [
                  "x402 v2",
                  "x402 v1",
                  null
                ]
              },
              "terms": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "price_usdc": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "pay_to": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "network": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "CAIP-2 id, e.g. eip155:8453"
                  },
                  "asset": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "scheme": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              },
              "listing": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "price_usdc": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "pay_to": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "network": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "CAIP-2 id, e.g. eip155:8453"
                  },
                  "asset": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "scheme": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              },
              "matches_listing": {
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "drift": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "field": {
                      "type": "string"
                    },
                    "listed": {},
                    "live": {},
                    "severity": {
                      "const": "high"
                    }
                  }
                }
              },
              "uptime_7d": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "up": {
                    "type": "integer"
                  },
                  "checks": {
                    "type": "integer"
                  }
                }
              },
              "avg_ms": {
                "type": [
                  "number",
                  "null"
                ]
              }
            }
          },
          "endpoints": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "method": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                }
              }
            }
          },
          "error": {
            "type": "string"
          }
        }
      }
    }
  }
}
