{
  "openapi": "3.1.0",
  "info": {
    "title": "AgentReady Monitor API",
    "version": "1.0.0",
    "description": "Everything the dashboard does, this API does too. Every response carries a meta.pricing field — currently {\"model\":\"free\"}, ready for agent payments over HTTP 402.",
    "contact": {
      "name": "The Autopilot",
      "url": "https://the-autopilot.com"
    }
  },
  "servers": [
    {
      "url": "https://ai-agent-ready.com",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "cases",
      "description": "Cases, runs and results"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "API key from the dashboard. Header: Authorization: Bearer <key>"
      }
    },
    "schemas": {
      "Meta": {
        "type": "object",
        "required": [
          "pricing",
          "generated_at",
          "docs"
        ],
        "properties": {
          "pricing": {
            "type": "object",
            "properties": {
              "model": {
                "type": "string",
                "enum": [
                  "free"
                ]
              }
            }
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "docs": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          }
        }
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/api/v1/cases": {
      "get": {
        "operationId": "list_cases",
        "summary": "All cases owned by the key holder",
        "description": "Returns every case belonging to the account behind the API key, including the current overall score and the time of the last run.",
        "tags": [
          "cases"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "example": {
                  "cases": [
                    {
                      "id": "4f1e9b2c-0d8a-4f7b-9d21-1b7c0c9a55e1",
                      "name": "Beispiel CRM",
                      "domain": "beispiel-crm.de",
                      "kategorie": "CRM software for trade businesses",
                      "konkurrenten": [
                        "Craftnote",
                        "Meisterwerk",
                        "ToolTime"
                      ],
                      "status": "active",
                      "latest_score": 44,
                      "last_run_at": "2026-08-01T03:12:00.000Z"
                    }
                  ],
                  "meta": {
                    "pricing": {
                      "model": "free"
                    },
                    "generated_at": "2026-08-25T09:12:44.000Z",
                    "docs": "https://ai-agent-ready.com/docs/api"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Bearer token missing or unknown.",
            "content": {
              "application/json": {
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Bearer token missing or unknown."
                  },
                  "meta": {
                    "pricing": {
                      "model": "free"
                    },
                    "generated_at": "2026-08-25T09:12:44.000Z",
                    "docs": "https://ai-agent-ready.com/docs/api"
                  }
                }
              }
            }
          },
          "403": {
            "description": "No Monitor account exists for this key.",
            "content": {
              "application/json": {
                "example": {
                  "error": {
                    "code": "no_account",
                    "message": "No Monitor account exists for this key."
                  },
                  "meta": {
                    "pricing": {
                      "model": "free"
                    },
                    "generated_at": "2026-08-25T09:12:44.000Z",
                    "docs": "https://ai-agent-ready.com/docs/api"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cases/{id}/summary": {
      "get": {
        "operationId": "get_case_summary",
        "summary": "Current score and share of answer",
        "description": "The result of the most recent finished run: overall score, score per model, share of answer against every competitor, top gaps and the delta to the previous run.",
        "tags": [
          "cases"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Case id (UUID).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "example": {
                  "case": {
                    "id": "4f1e9b2c-0d8a-4f7b-9d21-1b7c0c9a55e1",
                    "name": "Beispiel CRM"
                  },
                  "run": {
                    "id": "9a0c...",
                    "label": "Aug 26",
                    "kind": "monthly",
                    "finished_at": "2026-08-01T03:41:00.000Z"
                  },
                  "summary": {
                    "total_score": 44,
                    "per_model": {
                      "openai": 48,
                      "anthropic": 39,
                      "perplexity": 51,
                      "google": 38
                    },
                    "share_of_answer": [
                      {
                        "name": "Craftnote",
                        "share": 0.8,
                        "mentions": 8,
                        "total": 10,
                        "is_self": false
                      },
                      {
                        "name": "Beispiel CRM",
                        "share": 0.4,
                        "mentions": 4,
                        "total": 10,
                        "is_self": true
                      }
                    ],
                    "top_gaps": [
                      "Preise werden nicht genannt",
                      "Keine Aussage zur Testphase"
                    ],
                    "delta": {
                      "total_score": -6,
                      "per_model": {
                        "openai": -4
                      },
                      "previous_run_id": "7c21..."
                    }
                  },
                  "meta": {
                    "pricing": {
                      "model": "free"
                    },
                    "generated_at": "2026-08-25T09:12:44.000Z",
                    "docs": "https://ai-agent-ready.com/docs/api"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Case does not exist or belongs to another account.",
            "content": {
              "application/json": {
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Case does not exist or belongs to another account."
                  },
                  "meta": {
                    "pricing": {
                      "model": "free"
                    },
                    "generated_at": "2026-08-25T09:12:44.000Z",
                    "docs": "https://ai-agent-ready.com/docs/api"
                  }
                }
              }
            }
          },
          "409": {
            "description": "No run has finished for this case yet.",
            "content": {
              "application/json": {
                "example": {
                  "error": {
                    "code": "no_run",
                    "message": "No run has finished for this case yet."
                  },
                  "meta": {
                    "pricing": {
                      "model": "free"
                    },
                    "generated_at": "2026-08-25T09:12:44.000Z",
                    "docs": "https://ai-agent-ready.com/docs/api"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cases/{id}/runs": {
      "get": {
        "operationId": "list_runs",
        "summary": "Runs with score and delta",
        "description": "All measurement runs of a case, newest first, with status, overall score and the delta to the preceding run.",
        "tags": [
          "cases"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Case id (UUID).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum number of runs (1–100).",
            "schema": {
              "type": "integer",
              "default": 24
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "example": {
                  "runs": [
                    {
                      "id": "9a0c...",
                      "label": "Aug 26",
                      "kind": "monthly",
                      "status": "done",
                      "scheduled_for": "2026-08-01T03:00:00.000Z",
                      "finished_at": "2026-08-01T03:41:00.000Z",
                      "total_score": 44,
                      "delta": -6
                    }
                  ],
                  "meta": {
                    "pricing": {
                      "model": "free"
                    },
                    "generated_at": "2026-08-25T09:12:44.000Z",
                    "docs": "https://ai-agent-ready.com/docs/api"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Case does not exist or belongs to another account.",
            "content": {
              "application/json": {
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Case does not exist or belongs to another account."
                  },
                  "meta": {
                    "pricing": {
                      "model": "free"
                    },
                    "generated_at": "2026-08-25T09:12:44.000Z",
                    "docs": "https://ai-agent-ready.com/docs/api"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "create_run",
        "summary": "Trigger a manual measurement run (Pro)",
        "description": "Queues a run. The worker picks it up within seconds. Pro plan only; a run that is already queued or in progress for the same case is not duplicated.",
        "tags": [
          "cases"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Case id (UUID).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "description": "Optional label for the run.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "label": "After relaunch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "example": {
                  "run": {
                    "id": "b71f...",
                    "label": "After relaunch",
                    "kind": "manual",
                    "status": "queued"
                  },
                  "meta": {
                    "pricing": {
                      "model": "free"
                    },
                    "generated_at": "2026-08-25T09:12:44.000Z",
                    "docs": "https://ai-agent-ready.com/docs/api"
                  }
                }
              }
            }
          },
          "402": {
            "description": "The plan does not allow manual re-runs.",
            "content": {
              "application/json": {
                "example": {
                  "error": {
                    "code": "plan_required",
                    "message": "The plan does not allow manual re-runs."
                  },
                  "meta": {
                    "pricing": {
                      "model": "free"
                    },
                    "generated_at": "2026-08-25T09:12:44.000Z",
                    "docs": "https://ai-agent-ready.com/docs/api"
                  }
                }
              }
            }
          },
          "409": {
            "description": "A run is already queued or in progress for this case.",
            "content": {
              "application/json": {
                "example": {
                  "error": {
                    "code": "run_pending",
                    "message": "A run is already queued or in progress for this case."
                  },
                  "meta": {
                    "pricing": {
                      "model": "free"
                    },
                    "generated_at": "2026-08-25T09:12:44.000Z",
                    "docs": "https://ai-agent-ready.com/docs/api"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "x-mcp": {
    "note": "The Monitor MCP server (Cloudflare Worker, Agents SDK) consumes only this API. Each tool maps 1:1 to an endpoint.",
    "tools": [
      {
        "tool": "list_cases",
        "method": "GET",
        "path": "/api/v1/cases"
      },
      {
        "tool": "get_case_summary",
        "method": "GET",
        "path": "/api/v1/cases/{id}/summary"
      },
      {
        "tool": "list_runs",
        "method": "GET",
        "path": "/api/v1/cases/{id}/runs"
      },
      {
        "tool": "create_run",
        "method": "POST",
        "path": "/api/v1/cases/{id}/runs"
      }
    ]
  }
}