{
  "openapi": "3.1.0",
  "info": {
    "title": "Avizo Public API",
    "version": "1.0.0",
    "description": "Read access to your tracked items (documents, authorizations, deadlines). Single endpoint for now — hand-maintained minimal spec, kept in sync with /docs/api-reference. API keys are issued in the dashboard (Settings → API Keys, Pro/Fleet plans). See /auth.md.",
    "contact": {
      "url": "https://avizo.ro/contact"
    }
  },
  "servers": [
    {
      "url": "https://avizo.ro"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/api/v1/items": {
      "get": {
        "operationId": "listItems",
        "summary": "List the authenticated tenant's tracked items",
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]*$"
            },
            "description": "Filter by category slug (e.g. vehicle_itp)"
          },
          {
            "name": "expiring_within_days",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            },
            "description": "Only items expiring within N days"
          },
          {
            "name": "archived",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "true = archived items only (default: active only)"
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope { ok: true, data: [...] } — items with category, alert rule, expiry.",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix timestamp"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ItemsResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "API key (avizo_pk_…) from dashboard Settings → API Keys. Pro: 1000 req/h, Fleet: 5000 req/h."
      }
    },
    "schemas": {
      "ItemsResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                },
                "categoryId": {
                  "type": "string"
                },
                "entityName": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "expiresAt": {
                  "type": "string",
                  "format": "date-time"
                },
                "notes": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "category": {
                  "type": "object"
                },
                "alertRule": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "ErrorEnvelope": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "const": false
          },
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "examples": [
                  "INVALID_API_KEY",
                  "VALIDATION_ERROR",
                  "RATE_LIMIT_EXCEEDED"
                ]
              },
              "message": {
                "type": "string",
                "description": "Romanian, user-facing"
              }
            }
          }
        }
      }
    },
    "responses": {
      "Error": {
        "description": "Error envelope { ok: false, error: { code, message } }",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            }
          }
        }
      }
    }
  }
}