{
  "openapi": "3.1.0",
  "info": {
    "title": "Open Deals Agent API",
    "version": "1.0.0",
    "description": "Read-only REST actions and MCP tools. Begin at /AGENTS.md. Use the live action registry to check feature availability."
  },
  "servers": [
    {
      "url": "/"
    }
  ],
  "paths": {
    "/api/agent/v1/actions": {
      "get": {
        "summary": "Read the live registry and enabled actions",
        "responses": {
          "200": {
            "description": "Registry with action schemas, scopes and limits"
          }
        }
      }
    },
    "/api/mcp": {
      "post": {
        "summary": "MCP Streamable HTTP",
        "description": "Stateless JSON-RPC. Send Accept: application/json, text/event-stream and follow /AGENTS.md. An invalid supplied bearer is rejected before JSON-RPC.",
        "security": [
          {},
          {
            "agentBearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "202": {
            "description": "Notification accepted"
          },
          "401": {
            "description": "Invalid token",
            "$ref": "#/components/responses/AgentError"
          },
          "403": {
            "description": "Origin or host rejected",
            "$ref": "#/components/responses/AgentError"
          },
          "429": {
            "description": "Rate limited",
            "$ref": "#/components/responses/AgentError"
          }
        }
      }
    },
    "/api/agent/v1/tokens": {
      "get": {
        "summary": "List your personal token metadata",
        "security": [
          {
            "browserSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Token metadata",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AgentTokenMetadata"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Sign-in required",
            "$ref": "#/components/responses/AgentError"
          }
        }
      },
      "post": {
        "summary": "Create a personal token",
        "description": "Browser session and app origin rules apply. Copy the secret from this response.",
        "security": [
          {
            "browserSession": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateAgentToken"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Secret and metadata",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "token",
                    "item"
                  ],
                  "properties": {
                    "token": {
                      "type": "string"
                    },
                    "item": {
                      "$ref": "#/components/schemas/AgentTokenMetadata"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "$ref": "#/components/responses/AgentError"
          },
          "401": {
            "description": "Sign-in required",
            "$ref": "#/components/responses/AgentError"
          },
          "403": {
            "description": "Origin rejected",
            "$ref": "#/components/responses/AgentError"
          },
          "413": {
            "description": "Request too large",
            "$ref": "#/components/responses/AgentError"
          },
          "415": {
            "description": "JSON required",
            "$ref": "#/components/responses/AgentError"
          },
          "429": {
            "description": "Rate limited",
            "$ref": "#/components/responses/AgentError"
          }
        }
      }
    },
    "/api/agent/v1/tokens/{id}": {
      "delete": {
        "summary": "Revoke a personal token",
        "description": "Send Content-Type: application/json. Browser session and app origin rules apply.",
        "security": [
          {
            "browserSession": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{32}$"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Revocation accepted"
          },
          "401": {
            "description": "Sign-in required",
            "$ref": "#/components/responses/AgentError"
          },
          "403": {
            "description": "Origin rejected",
            "$ref": "#/components/responses/AgentError"
          },
          "415": {
            "description": "JSON required",
            "$ref": "#/components/responses/AgentError"
          }
        }
      }
    },
    "/api/agent/v1/actions/search_listings": {
      "post": {
        "operationId": "search_listings",
        "summary": "Search listings",
        "description": "Search public vehicle listings. Results use the marketplace sort and pagination. Partner entries have negative IDs and link to their fleet via partner.externalId.",
        "x-scope": null,
        "x-backing-route": "GET /api/listings",
        "security": [
          {},
          {
            "agentBearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "input"
                ],
                "additionalProperties": false,
                "properties": {
                  "input": {
                    "type": "object",
                    "properties": {
                      "q": {
                        "type": "string",
                        "maxLength": 80
                      },
                      "make": {
                        "type": "string",
                        "maxLength": 40
                      },
                      "model": {
                        "type": "string",
                        "maxLength": 60
                      },
                      "page": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 1000000
                      }
                    },
                    "additionalProperties": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Read result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "make": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "model": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "priceEur": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "demo": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "demo"
                        ]
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "demoTotal": {
                      "type": "integer"
                    },
                    "page": {
                      "type": "integer"
                    },
                    "pages": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "items",
                    "total",
                    "demoTotal",
                    "page",
                    "pages"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Input failed validation",
            "$ref": "#/components/responses/AgentError"
          },
          "401": {
            "description": "Missing required bearer or invalid token",
            "$ref": "#/components/responses/AgentError"
          },
          "403": {
            "description": "Insufficient scope",
            "$ref": "#/components/responses/AgentError"
          },
          "404": {
            "description": "Unknown action or resource not found",
            "$ref": "#/components/responses/AgentError"
          },
          "413": {
            "description": "Request too large",
            "$ref": "#/components/responses/AgentError"
          },
          "415": {
            "description": "JSON required",
            "$ref": "#/components/responses/AgentError"
          },
          "429": {
            "description": "Rate limited",
            "$ref": "#/components/responses/AgentError"
          }
        }
      }
    },
    "/api/agent/v1/actions/view_listing": {
      "post": {
        "operationId": "view_listing",
        "summary": "View listing",
        "description": "Read a public listing by its positive ID, including related listings.",
        "x-scope": null,
        "x-backing-route": "GET /api/listings/{id}",
        "security": [
          {},
          {
            "agentBearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "input"
                ],
                "additionalProperties": false,
                "properties": {
                  "input": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "pattern": "^[1-9][0-9]{0,14}$"
                      }
                    },
                    "required": [
                      "id"
                    ],
                    "additionalProperties": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Read result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "listing": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer"
                        },
                        "make": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "model": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "priceEur": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "demo": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "id",
                        "demo"
                      ]
                    },
                    "more": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "make": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "model": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "priceEur": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "demo": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "demo"
                        ]
                      }
                    }
                  },
                  "required": [
                    "listing",
                    "more"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Input failed validation",
            "$ref": "#/components/responses/AgentError"
          },
          "401": {
            "description": "Missing required bearer or invalid token",
            "$ref": "#/components/responses/AgentError"
          },
          "403": {
            "description": "Insufficient scope",
            "$ref": "#/components/responses/AgentError"
          },
          "404": {
            "description": "Unknown action or resource not found",
            "$ref": "#/components/responses/AgentError"
          },
          "413": {
            "description": "Request too large",
            "$ref": "#/components/responses/AgentError"
          },
          "415": {
            "description": "JSON required",
            "$ref": "#/components/responses/AgentError"
          },
          "429": {
            "description": "Rate limited",
            "$ref": "#/components/responses/AgentError"
          }
        }
      }
    },
    "/api/agent/v1/actions/buyer_shortlist": {
      "post": {
        "operationId": "buyer_shortlist",
        "summary": "Buyer shortlist",
        "description": "Turn a plain-language car request into structured filters and return up to 6 genuine listings ranked by transparent, field-based score components, with reasons, unknown fields and real-only price position (needs 8+ comparables). Read-only: it never saves, contacts, bids or buys. Location and seller type are reported as unsupported.",
        "x-scope": null,
        "x-backing-route": "POST /api/buyer/runs",
        "security": [
          {},
          {
            "agentBearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "input"
                ],
                "additionalProperties": false,
                "properties": {
                  "input": {
                    "type": "object",
                    "properties": {
                      "text": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 500
                      },
                      "locale": {
                        "type": "string",
                        "enum": [
                          "pt-PT",
                          "en",
                          "es"
                        ]
                      }
                    },
                    "required": [
                      "text"
                    ],
                    "additionalProperties": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Read result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "run": {
                      "type": "object"
                    },
                    "intent": {
                      "type": "object"
                    },
                    "searchQuery": {
                      "type": "string"
                    },
                    "steps": {
                      "type": "array"
                    },
                    "matched": {
                      "type": "integer"
                    },
                    "shortlist": {
                      "type": "array"
                    }
                  },
                  "required": [
                    "run",
                    "intent",
                    "shortlist"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Input failed validation",
            "$ref": "#/components/responses/AgentError"
          },
          "401": {
            "description": "Missing required bearer or invalid token",
            "$ref": "#/components/responses/AgentError"
          },
          "403": {
            "description": "Insufficient scope",
            "$ref": "#/components/responses/AgentError"
          },
          "404": {
            "description": "Unknown action or resource not found",
            "$ref": "#/components/responses/AgentError"
          },
          "413": {
            "description": "Request too large",
            "$ref": "#/components/responses/AgentError"
          },
          "415": {
            "description": "JSON required",
            "$ref": "#/components/responses/AgentError"
          },
          "429": {
            "description": "Rate limited",
            "$ref": "#/components/responses/AgentError"
          }
        }
      }
    },
    "/api/agent/v1/actions/view_auction_status": {
      "post": {
        "operationId": "view_auction_status",
        "summary": "View auction status",
        "description": "Read the public status of an auction. Available when auctions are enabled.",
        "x-scope": null,
        "x-backing-route": "GET /api/auctions/{id}",
        "security": [
          {},
          {
            "agentBearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "input"
                ],
                "additionalProperties": false,
                "properties": {
                  "input": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "pattern": "^[1-9][0-9]{0,14}$"
                      }
                    },
                    "required": [
                      "id"
                    ],
                    "additionalProperties": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Read result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "integer"
                    },
                    "listing_id": {
                      "type": "integer"
                    },
                    "status": {
                      "type": "string"
                    },
                    "demo": {
                      "type": "boolean"
                    },
                    "bid_count": {
                      "type": "integer"
                    },
                    "current_price": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "ends_at": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "listing_id",
                    "status",
                    "demo",
                    "bid_count",
                    "current_price",
                    "ends_at"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Input failed validation",
            "$ref": "#/components/responses/AgentError"
          },
          "401": {
            "description": "Missing required bearer or invalid token",
            "$ref": "#/components/responses/AgentError"
          },
          "403": {
            "description": "Insufficient scope",
            "$ref": "#/components/responses/AgentError"
          },
          "404": {
            "description": "Unknown action or resource not found",
            "$ref": "#/components/responses/AgentError"
          },
          "413": {
            "description": "Request too large",
            "$ref": "#/components/responses/AgentError"
          },
          "415": {
            "description": "JSON required",
            "$ref": "#/components/responses/AgentError"
          },
          "429": {
            "description": "Rate limited",
            "$ref": "#/components/responses/AgentError"
          }
        }
      }
    },
    "/api/agent/v1/actions/list_my_favourites": {
      "post": {
        "operationId": "list_my_favourites",
        "summary": "My favourites",
        "description": "Read the token owner’s saved listings and price alert status.",
        "x-scope": "favourites:read",
        "x-backing-route": "GET /api/favourites",
        "security": [
          {
            "agentBearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "input"
                ],
                "additionalProperties": false,
                "properties": {
                  "input": {
                    "type": "object",
                    "properties": {},
                    "additionalProperties": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Read result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ids": {
                      "type": "array",
                      "items": {
                        "type": "integer"
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "status": {
                            "type": "string"
                          },
                          "demo": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "status",
                          "demo"
                        ]
                      }
                    }
                  },
                  "required": [
                    "ids",
                    "items"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Input failed validation",
            "$ref": "#/components/responses/AgentError"
          },
          "401": {
            "description": "Missing required bearer or invalid token",
            "$ref": "#/components/responses/AgentError"
          },
          "403": {
            "description": "Insufficient scope",
            "$ref": "#/components/responses/AgentError"
          },
          "404": {
            "description": "Unknown action or resource not found",
            "$ref": "#/components/responses/AgentError"
          },
          "413": {
            "description": "Request too large",
            "$ref": "#/components/responses/AgentError"
          },
          "415": {
            "description": "JSON required",
            "$ref": "#/components/responses/AgentError"
          },
          "429": {
            "description": "Rate limited",
            "$ref": "#/components/responses/AgentError"
          }
        }
      }
    },
    "/api/agent/v1/actions/list_my_saved_searches": {
      "post": {
        "operationId": "list_my_saved_searches",
        "summary": "My saved searches",
        "description": "Read the token owner’s saved search filters and alert settings.",
        "x-scope": "saved_searches:read",
        "x-backing-route": "GET /api/alerts",
        "security": [
          {
            "agentBearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "input"
                ],
                "additionalProperties": false,
                "properties": {
                  "input": {
                    "type": "object",
                    "properties": {},
                    "additionalProperties": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Read result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "name": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "params": {
                            "type": [
                              "object",
                              "array"
                            ]
                          },
                          "frequency": {
                            "type": "string"
                          },
                          "paused": {
                            "type": "boolean"
                          },
                          "expired": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "params",
                          "frequency",
                          "paused",
                          "expired"
                        ]
                      }
                    },
                    "deliverable": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "items",
                    "deliverable"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Input failed validation",
            "$ref": "#/components/responses/AgentError"
          },
          "401": {
            "description": "Missing required bearer or invalid token",
            "$ref": "#/components/responses/AgentError"
          },
          "403": {
            "description": "Insufficient scope",
            "$ref": "#/components/responses/AgentError"
          },
          "404": {
            "description": "Unknown action or resource not found",
            "$ref": "#/components/responses/AgentError"
          },
          "413": {
            "description": "Request too large",
            "$ref": "#/components/responses/AgentError"
          },
          "415": {
            "description": "JSON required",
            "$ref": "#/components/responses/AgentError"
          },
          "429": {
            "description": "Rate limited",
            "$ref": "#/components/responses/AgentError"
          }
        }
      }
    },
    "/api/agent/v1/actions/list_my_garage": {
      "post": {
        "operationId": "list_my_garage",
        "summary": "My garage",
        "description": "Read the token owner’s saved vehicles (user-entered make, model, year, mileage, fuel) and upcoming inspection, insurance and service reminders. No plate, VIN or history is stored.",
        "x-scope": "garage:read",
        "x-backing-route": "GET /api/garage",
        "security": [
          {
            "agentBearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "input"
                ],
                "additionalProperties": false,
                "properties": {
                  "input": {
                    "type": "object",
                    "properties": {},
                    "additionalProperties": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Read result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "nickname": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "make": {
                            "type": "string"
                          },
                          "model": {
                            "type": "string"
                          },
                          "year": {
                            "type": "integer"
                          },
                          "engine": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "fuel": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "km": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "reminders": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "kind": {
                                  "type": "string",
                                  "enum": [
                                    "mot",
                                    "insurance",
                                    "service"
                                  ]
                                },
                                "date": {
                                  "type": "string"
                                },
                                "days": {
                                  "type": "integer"
                                },
                                "state": {
                                  "type": "string",
                                  "enum": [
                                    "overdue",
                                    "soon",
                                    "scheduled"
                                  ]
                                }
                              },
                              "required": [
                                "kind",
                                "date",
                                "days",
                                "state"
                              ]
                            }
                          }
                        },
                        "required": [
                          "id",
                          "make",
                          "model",
                          "year",
                          "reminders"
                        ]
                      }
                    },
                    "limit": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "items",
                    "limit"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Input failed validation",
            "$ref": "#/components/responses/AgentError"
          },
          "401": {
            "description": "Missing required bearer or invalid token",
            "$ref": "#/components/responses/AgentError"
          },
          "403": {
            "description": "Insufficient scope",
            "$ref": "#/components/responses/AgentError"
          },
          "404": {
            "description": "Unknown action or resource not found",
            "$ref": "#/components/responses/AgentError"
          },
          "413": {
            "description": "Request too large",
            "$ref": "#/components/responses/AgentError"
          },
          "415": {
            "description": "JSON required",
            "$ref": "#/components/responses/AgentError"
          },
          "429": {
            "description": "Rate limited",
            "$ref": "#/components/responses/AgentError"
          }
        }
      }
    },
    "/api/agent/v1/actions/search_parts": {
      "post": {
        "operationId": "search_parts",
        "summary": "Search parts",
        "description": "Search the curated real automotive parts catalogue by keyword, OEM reference, category, or vehicle fitment.",
        "x-scope": null,
        "x-backing-route": "GET /api/parts",
        "security": [
          {},
          {
            "agentBearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "input"
                ],
                "additionalProperties": false,
                "properties": {
                  "input": {
                    "type": "object",
                    "properties": {
                      "q": {
                        "type": "string",
                        "maxLength": 100
                      },
                      "category": {
                        "type": "string",
                        "enum": [
                          "brakes",
                          "filters",
                          "suspension",
                          "lighting",
                          "bodywork",
                          "interior",
                          "tyres",
                          "electrical",
                          "engine"
                        ]
                      },
                      "make": {
                        "type": "string",
                        "maxLength": 60
                      },
                      "model": {
                        "type": "string",
                        "maxLength": 60
                      },
                      "year": {
                        "type": "string",
                        "pattern": "^[0-9]{4}$"
                      },
                      "engine": {
                        "type": "string",
                        "maxLength": 60
                      },
                      "page": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 10000
                      }
                    },
                    "additionalProperties": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Read result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "title": {
                            "type": "string"
                          },
                          "brand": {
                            "type": "string"
                          },
                          "category": {
                            "type": "string"
                          },
                          "demo": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "title",
                          "brand",
                          "category",
                          "demo"
                        ]
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "page": {
                      "type": "integer"
                    },
                    "pages": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "items",
                    "total",
                    "page",
                    "pages"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Input failed validation",
            "$ref": "#/components/responses/AgentError"
          },
          "401": {
            "description": "Missing required bearer or invalid token",
            "$ref": "#/components/responses/AgentError"
          },
          "403": {
            "description": "Insufficient scope",
            "$ref": "#/components/responses/AgentError"
          },
          "404": {
            "description": "Unknown action or resource not found",
            "$ref": "#/components/responses/AgentError"
          },
          "413": {
            "description": "Request too large",
            "$ref": "#/components/responses/AgentError"
          },
          "415": {
            "description": "JSON required",
            "$ref": "#/components/responses/AgentError"
          },
          "429": {
            "description": "Rate limited",
            "$ref": "#/components/responses/AgentError"
          }
        }
      }
    },
    "/api/agent/v1/actions/view_part": {
      "post": {
        "operationId": "view_part",
        "summary": "View part",
        "description": "Read a curated real part by its positive ID, including OEM references, licensed photos, fitment, and offers.",
        "x-scope": null,
        "x-backing-route": "GET /api/parts/{id}",
        "security": [
          {},
          {
            "agentBearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "input"
                ],
                "additionalProperties": false,
                "properties": {
                  "input": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "pattern": "^[1-9][0-9]{0,14}$"
                      }
                    },
                    "required": [
                      "id"
                    ],
                    "additionalProperties": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Read result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "part": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer"
                        },
                        "title": {
                          "type": "string"
                        },
                        "brand": {
                          "type": "string"
                        },
                        "category": {
                          "type": "string"
                        },
                        "demo": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "id",
                        "title",
                        "brand",
                        "category",
                        "demo"
                      ]
                    }
                  },
                  "required": [
                    "part"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Input failed validation",
            "$ref": "#/components/responses/AgentError"
          },
          "401": {
            "description": "Missing required bearer or invalid token",
            "$ref": "#/components/responses/AgentError"
          },
          "403": {
            "description": "Insufficient scope",
            "$ref": "#/components/responses/AgentError"
          },
          "404": {
            "description": "Unknown action or resource not found",
            "$ref": "#/components/responses/AgentError"
          },
          "413": {
            "description": "Request too large",
            "$ref": "#/components/responses/AgentError"
          },
          "415": {
            "description": "JSON required",
            "$ref": "#/components/responses/AgentError"
          },
          "429": {
            "description": "Rate limited",
            "$ref": "#/components/responses/AgentError"
          }
        }
      }
    },
    "/api/agent/v1/actions/find_parts": {
      "post": {
        "operationId": "find_parts",
        "summary": "Find parts",
        "description": "Parse a natural-language part request, OEM/part number, or vehicle context and return separated curated real parts and labeled example matches with honest fitment confidence.",
        "x-scope": null,
        "x-backing-route": "POST /api/parts/finder",
        "security": [
          {},
          {
            "agentBearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "input"
                ],
                "additionalProperties": false,
                "properties": {
                  "input": {
                    "type": "object",
                    "properties": {
                      "query": {
                        "type": "string",
                        "maxLength": 400
                      },
                      "oemOrPartNumber": {
                        "type": "string",
                        "maxLength": 80
                      },
                      "photoNote": {
                        "type": "string",
                        "maxLength": 400
                      },
                      "locale": {
                        "type": "string",
                        "enum": [
                          "pt-PT",
                          "en",
                          "es"
                        ]
                      },
                      "vehicle": {
                        "type": "object",
                        "properties": {
                          "make": {
                            "type": "string",
                            "maxLength": 80
                          },
                          "model": {
                            "type": "string",
                            "maxLength": 80
                          },
                          "year": {
                            "type": [
                              "string",
                              "integer"
                            ]
                          },
                          "engine": {
                            "type": "string",
                            "maxLength": 80
                          }
                        },
                        "additionalProperties": false
                      }
                    },
                    "additionalProperties": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Read result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "mode": {
                      "type": "string"
                    },
                    "extracted": {
                      "type": "object"
                    },
                    "clarifyingQuestions": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "matches": {
                      "type": "object",
                      "properties": {
                        "curated": {
                          "type": "array"
                        },
                        "examples": {
                          "type": "array"
                        }
                      },
                      "required": [
                        "curated",
                        "examples"
                      ]
                    },
                    "fitmentConfidence": {
                      "type": "string"
                    },
                    "compatibilityNotice": {
                      "type": "string"
                    },
                    "nextActions": {
                      "type": "array"
                    }
                  },
                  "required": [
                    "mode",
                    "extracted",
                    "clarifyingQuestions",
                    "matches",
                    "fitmentConfidence",
                    "compatibilityNotice",
                    "nextActions"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Input failed validation",
            "$ref": "#/components/responses/AgentError"
          },
          "401": {
            "description": "Missing required bearer or invalid token",
            "$ref": "#/components/responses/AgentError"
          },
          "403": {
            "description": "Insufficient scope",
            "$ref": "#/components/responses/AgentError"
          },
          "404": {
            "description": "Unknown action or resource not found",
            "$ref": "#/components/responses/AgentError"
          },
          "413": {
            "description": "Request too large",
            "$ref": "#/components/responses/AgentError"
          },
          "415": {
            "description": "JSON required",
            "$ref": "#/components/responses/AgentError"
          },
          "429": {
            "description": "Rate limited",
            "$ref": "#/components/responses/AgentError"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "agentBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Personal agent token created by the account owner at /agents."
      },
      "browserSession": {
        "type": "apiKey",
        "name": "od_session",
        "in": "cookie"
      }
    },
    "schemas": {
      "AgentTokenMetadata": {
        "type": "object",
        "required": [
          "id",
          "name",
          "scopes",
          "createdAt",
          "expiresAt",
          "lastUsedAt",
          "revokedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[0-9a-f]{32}$"
          },
          "name": {
            "type": "string"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastUsedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "revokedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "CreateAgentToken": {
        "type": "object",
        "required": [
          "name"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "scopes": {
            "type": "array",
            "default": [],
            "uniqueItems": true,
            "items": {
              "type": "string",
              "enum": [
                "favourites:read",
                "saved_searches:read",
                "garage:read"
              ]
            }
          },
          "lifetimeDays": {
            "type": "integer",
            "minimum": 1,
            "default": 90,
            "maximum": 365
          }
        }
      }
    },
    "responses": {
      "AgentError": {
        "description": "Request error",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "required": [
                "error"
              ],
              "properties": {
                "error": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}
