{
  "openapi": "3.1.0",
  "info": {
    "title": "Паспорт ИИ-агента — API проверки и реестра",
    "version": "1.0.0",
    "description": "Проверка паспорта ИИ-агента (формат 0.1) и чтение реестра выданных паспортов. Ключ не нужен; лимит проверок — 10 в минуту с одного адреса.",
    "license": {
      "name": "CC BY 4.0",
      "url": "https://creativecommons.org/licenses/by/4.0/"
    },
    "contact": {
      "name": "ООО «САРМАТЕХ»",
      "email": "info@a2aprotocol.ru",
      "url": "https://xn----7sbbaom0ddhbmjqf.xn--p1ai/dlya-razrabotchikov/"
    }
  },
  "servers": [
    {
      "url": "https://xn----7sbbaom0ddhbmjqf.xn--p1ai"
    }
  ],
  "paths": {
    "/api/v1/check": {
      "get": {
        "operationId": "checkPassportByUrl",
        "summary": "Загрузить паспорт с сайта и проверить",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Домен (example.ru) или адрес паспорта, можно с #фрагментом"
          }
        ],
        "responses": {
          "200": {
            "description": "Результат проверки",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "verdict": {
                      "type": "string",
                      "enum": [
                        "valid",
                        "invalid",
                        "inactive",
                        "fetch_error"
                      ]
                    },
                    "verdict_text": {
                      "type": "string"
                    },
                    "level": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "enum": [
                        "K2",
                        "K3",
                        null
                      ]
                    },
                    "format": {
                      "type": "string"
                    },
                    "checked_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "duration_ms": {
                      "type": "integer"
                    },
                    "source": {
                      "type": "object"
                    },
                    "passports": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "counts": {
                      "type": "object",
                      "properties": {
                        "ok": {
                          "type": "integer"
                        },
                        "err": {
                          "type": "integer"
                        },
                        "warn": {
                          "type": "integer"
                        },
                        "info": {
                          "type": "integer"
                        }
                      }
                    },
                    "checks": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "status": {
                            "type": "string",
                            "enum": [
                              "ok",
                              "err",
                              "warn",
                              "info"
                            ]
                          },
                          "code": {
                            "type": "string"
                          },
                          "path": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "registry": {
                      "type": "object"
                    },
                    "note": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Не указан адрес"
          },
          "429": {
            "description": "Превышен лимит"
          }
        }
      },
      "post": {
        "operationId": "checkPassport",
        "summary": "Проверить по адресу или переданный паспорт",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "url": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "url"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "passport": {
                        "type": "object"
                      }
                    },
                    "required": [
                      "passport"
                    ]
                  },
                  {
                    "$ref": "https://xn----7sbbaom0ddhbmjqf.xn--p1ai/.well-known/agent-passport.schema.json"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Результат проверки",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "verdict": {
                      "type": "string",
                      "enum": [
                        "valid",
                        "invalid",
                        "inactive",
                        "fetch_error"
                      ]
                    },
                    "verdict_text": {
                      "type": "string"
                    },
                    "level": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "enum": [
                        "K2",
                        "K3",
                        null
                      ]
                    },
                    "format": {
                      "type": "string"
                    },
                    "checked_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "duration_ms": {
                      "type": "integer"
                    },
                    "source": {
                      "type": "object"
                    },
                    "passports": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "counts": {
                      "type": "object",
                      "properties": {
                        "ok": {
                          "type": "integer"
                        },
                        "err": {
                          "type": "integer"
                        },
                        "warn": {
                          "type": "integer"
                        },
                        "info": {
                          "type": "integer"
                        }
                      }
                    },
                    "checks": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "status": {
                            "type": "string",
                            "enum": [
                              "ok",
                              "err",
                              "warn",
                              "info"
                            ]
                          },
                          "code": {
                            "type": "string"
                          },
                          "path": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "registry": {
                      "type": "object"
                    },
                    "note": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Больше 256 КБ"
          },
          "429": {
            "description": "Превышен лимит"
          }
        }
      }
    },
    "/api/v1/passports": {
      "get": {
        "operationId": "listPassports",
        "summary": "Реестр выданных паспортов",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "confirmed",
                "unconfirmed",
                "suspended",
                "revoked"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Список",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Entry"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/passports/{number}": {
      "get": {
        "operationId": "getPassport",
        "summary": "Запись реестра",
        "parameters": [
          {
            "name": "number",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^AP-\\d{4}-\\d{6}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Запись",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "item": {
                      "$ref": "#/components/schemas/Entry"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Нет такого номера"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Entry": {
        "type": "object",
        "properties": {
          "number": {
            "type": "string"
          },
          "owner": {
            "type": "string"
          },
          "owner_inn": {
            "type": "string"
          },
          "owner_site": {
            "type": "string"
          },
          "agent_name": {
            "type": "string"
          },
          "agent_version": {
            "type": "string"
          },
          "purpose": {
            "type": "string"
          },
          "agent_url": {
            "type": "string"
          },
          "limits": {
            "type": "string"
          },
          "valid_until": {
            "type": "string"
          },
          "level": {
            "type": "string"
          },
          "signed": {
            "type": "boolean"
          },
          "passport_url": {
            "type": "string"
          },
          "passport_id": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "status_text": {
            "type": "string"
          },
          "registered_at": {
            "type": "string"
          },
          "checked_at": {
            "type": "string"
          },
          "last_check": {
            "type": "object"
          },
          "history": {
            "type": "array"
          },
          "card_url": {
            "type": "string"
          }
        }
      }
    }
  }
}
