{
  "openapi": "3.1.0",
  "info": {
    "title": "Becda Çoklu Kiracı Karar Motoru API",
    "version": "2.0.0",
    "description": "Two contracts on the same engine. /v2 is the English contract (recommended for new integrations); /v1 is the original Turkish contract and stays fully supported. Both share tenants, data, quota and limits: the decision quota is used only by decision calls (/predict, /predict-batch per record). Learning calls (/learn, /learn-batch, /rollback, /forget) do not use it; a learning cap of 20 times the decision quota prevents abuse. Batch endpoints accept up to 1000 records and 1 MiB per request on every plan. Read-only keys (becda_ro_...) can call /predict, /predict-batch, /status, /whoami, /feedback, /rules, /rules/test and /rules-telemetry. /rollback and /forget replay the tenant's history, so on /v2 they are asynchronous: they return 202 with a job id; poll GET /jobs/{job_id}. Predictions keep working during the job and use the previous state until the job finishes. Code migration endpoints are available in /v1 only for now.\n\nDecision Rules (Karar Kurallari): tenants can define deterministic pre-rules (before Becda) and post-rules (after Becda) as visual decision tables in the Portal. Published rules run automatically on /predict and /tahmin. Agents and integrations can inspect rules (GET /rules), dry-run them with 0 quota (POST /rules/test), monitor ZDR-safe hit counts (GET /rules-telemetry), and stage drafts (POST /rules/draft — write key required; live traffic changes only when a person publishes in the Portal).\n\nIntegrations should send the header X-Becda-Client: <name>/<version> (for example odoo-18/1.0). Becda keeps only content-free daily counters (calls, duration, automatic/human share) per client; record content, field values, codes and item ids are never stored. Send item_id on /predict and again on /learn to see how often suggestions are accepted. POST /feedback sends a bug report, feature request or accuracy note (read-only keys allowed, 20 per tenant per day, does not use quota). Do not write invoice content in feedback text.\n\nTürkçe: /v1 özgün Türkçe sözleşmedir ve tam desteklenir; /v2 aynı motor üzerinde İngilizce sözleşmedir.",
    "contact": {
      "name": "Becda Teknik Destek",
      "email": "support@becda.com",
      "url": "https://becda.com"
    }
  },
  "servers": [
    {
      "url": "https://api.becda.com",
      "description": "Üretim / Sandbox API Sunucusu"
    }
  ],
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Kiracıya özel Bearer API anahtarı (ör. becda_sbx_...)"
      }
    },
    "parameters": {
      "KiraciId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "Kiracı kimliği (^[A-Za-z0-9_-]{1,64}$)",
        "schema": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,64}$"
        }
      }
    },
    "schemas": {
      "HataYaniti": {
        "type": "object",
        "required": [
          "kod",
          "hata"
        ],
        "properties": {
          "kod": {
            "type": "string"
          },
          "hata": {
            "type": "string"
          }
        }
      },
      "TahminIstegi": {
        "type": "object",
        "required": [
          "x"
        ],
        "properties": {
          "x": {
            "type": "object",
            "additionalProperties": true,
            "description": "Ham yapısal alanlar (JSON nesnesi)"
          },
          "metin": {
            "type": [
              "string",
              "null"
            ],
            "description": "Opsiyonel kısa serbest metin açıklaması"
          },
          "kalem_kimligi": {
            "type": [
              "string",
              "integer",
              "null"
            ],
            "description": "Opsiyonel harici kayıt takip kimliği"
          }
        }
      },
      "TahminYaniti": {
        "type": "object",
        "properties": {
          "kiraci_id": {
            "type": "string"
          },
          "kod": {
            "type": [
              "string",
              "null"
            ]
          },
          "olasilik": {
            "type": [
              "number",
              "null"
            ]
          },
          "guven": {
            "type": "number"
          },
          "yol": {
            "type": "string"
          },
          "otomatik": {
            "type": "boolean"
          },
          "kaynak": {
            "type": "string"
          },
          "bildirim": {
            "type": "boolean"
          },
          "alarm": {
            "type": "boolean"
          },
          "fren_esigi": {
            "type": "number"
          },
          "soguk_baslangic": {
            "type": "boolean"
          }
        }
      },
      "OgrenIstegi": {
        "type": "object",
        "required": [
          "x",
          "y",
          "gun"
        ],
        "properties": {
          "x": {
            "type": "object",
            "additionalProperties": true
          },
          "y": {
            "type": "string",
            "description": "Doğrulanmış hedef kod"
          },
          "gun": {
            "type": "string",
            "description": "Kayıt günü (ör. 20260115)"
          },
          "metin": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "UnutIstegi": {
        "type": "object",
        "required": [
          "yuva",
          "deger"
        ],
        "properties": {
          "yuva": {
            "type": "string",
            "description": "Alan adı"
          },
          "deger": {
            "description": "Silinecek alan değeri"
          }
        }
      },
      "KodListesiIstegi": {
        "type": "object",
        "required": [
          "kodlar"
        ],
        "properties": {
          "kodlar": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "TasimaKanitiIstegi": {
        "type": "object",
        "required": [
          "eski"
        ],
        "properties": {
          "eski": {
            "type": "string"
          },
          "yeni": {
            "type": [
              "string",
              "null"
            ]
          },
          "son": {
            "type": "integer",
            "default": 200
          }
        }
      },
      "TasiIstegi": {
        "type": "object",
        "required": [
          "esleme",
          "onay"
        ],
        "properties": {
          "esleme": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Eski kod → yeni kod eşleme sözlüğü"
          },
          "onay": {
            "type": "boolean",
            "const": true,
            "description": "Açık onay kilidi (true zorunlu)"
          }
        }
      },
      "TopluTahminIstegi": {
        "type": "object",
        "required": [
          "kayitlar"
        ],
        "properties": {
          "kayitlar": {
            "type": "array",
            "minItems": 1,
            "maxItems": 1000,
            "items": {
              "$ref": "#/components/schemas/TahminIstegi"
            }
          }
        }
      },
      "TopluOgrenIstegi": {
        "type": "object",
        "required": [
          "kayitlar"
        ],
        "properties": {
          "kayitlar": {
            "type": "array",
            "minItems": 1,
            "maxItems": 1000,
            "items": {
              "$ref": "#/components/schemas/OgrenIstegi"
            }
          }
        }
      },
      "TopluYanit": {
        "type": "object",
        "properties": {
          "islenen": {
            "type": "integer",
            "description": "İstekteki kayıt sayısı"
          },
          "basarili": {
            "type": "integer",
            "description": "Hatasız işlenen kayıt sayısı (yalnız bunlar sayaçtan düşer)"
          },
          "sonuclar": {
            "type": "array",
            "description": "Kayıtlarla aynı sırada. Hatalı kayıtta {\"sira\": i, \"hata\": \"...\"} döner; öbür kayıtlar işlenmeye devam eder.",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "V2Fields": {
        "type": "object",
        "additionalProperties": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "description": "Structured fields of the record, e.g. supplier tax id (hashed), unit, VAT rate. Use the same field names and value formats for learning and predicting."
      },
      "V2PredictRequest": {
        "type": "object",
        "required": [
          "fields"
        ],
        "properties": {
          "fields": {
            "$ref": "#/components/schemas/V2Fields"
          },
          "text": {
            "type": "string",
            "description": "Optional short item text. Do not put personal data here."
          },
          "item_id": {
            "type": "string",
            "description": "Optional stable id of the item (e.g. invoice-uuid:line)."
          }
        }
      },
      "V2LearnRequest": {
        "type": "object",
        "required": [
          "fields",
          "code",
          "date"
        ],
        "properties": {
          "fields": {
            "$ref": "#/components/schemas/V2Fields"
          },
          "code": {
            "type": "string",
            "description": "The code a person approved (e.g. account code 770)."
          },
          "date": {
            "type": [
              "integer",
              "string"
            ],
            "description": "Record date as YYYYMMDD."
          },
          "text": {
            "type": "string"
          },
          "item_id": {
            "type": "string",
            "description": "Optional. The same id sent to /predict. Lets Becda count how often a suggestion was accepted; only a salted hash is kept in memory for 7 days, never on disk."
          }
        }
      },
      "V2PredictResponse": {
        "type": "object",
        "properties": {
          "tenant_id": {
            "type": "string"
          },
          "code": {
            "type": [
              "string",
              "null"
            ],
            "description": "Suggested code, or null when there is no suggestion."
          },
          "confidence": {
            "type": "number",
            "description": "Between 0 and 1."
          },
          "auto_approved": {
            "type": "boolean",
            "description": "True only when the decision may be processed without a person."
          },
          "route": {
            "type": "string",
            "enum": [
              "confident",
              "known_pattern",
              "ask_human",
              "no_suggestion"
            ]
          },
          "reason": {
            "type": "string",
            "description": "Plain-English reason for the routing."
          },
          "audit": {
            "type": "boolean",
            "description": "Random quality audit: a confident decision sent to a person on purpose."
          },
          "alarm": {
            "type": "boolean",
            "description": "Automatic processing is paused after a bulk change in decisions."
          },
          "code_change_notice": {
            "type": "boolean",
            "description": "The code plan changed (closed or replaced code)."
          },
          "cold_start": {
            "type": "boolean",
            "description": "Early suggestion from few records; never automatic."
          }
        }
      },
      "V2BatchPredictRequest": {
        "type": "object",
        "required": [
          "records"
        ],
        "properties": {
          "records": {
            "type": "array",
            "minItems": 1,
            "maxItems": 1000,
            "items": {
              "$ref": "#/components/schemas/V2PredictRequest"
            }
          }
        }
      },
      "V2BatchLearnRequest": {
        "type": "object",
        "required": [
          "records"
        ],
        "properties": {
          "records": {
            "type": "array",
            "minItems": 1,
            "maxItems": 1000,
            "items": {
              "$ref": "#/components/schemas/V2LearnRequest"
            }
          }
        }
      },
      "V2BatchResponse": {
        "type": "object",
        "properties": {
          "processed": {
            "type": "integer"
          },
          "succeeded": {
            "type": "integer",
            "description": "Only these use quota."
          },
          "results": {
            "type": "array",
            "description": "Same order as the request. A bad record returns {\"index\": i, \"error\": {...}} and does not stop the others.",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "V2Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "not_found",
                  "invalid_tenant",
                  "unauthorized",
                  "forbidden",
                  "account_suspended",
                  "plan_expired",
                  "rate_limited",
                  "quota_exceeded",
                  "learning_cap_reached",
                  "invalid_request",
                  "too_many_records",
                  "body_too_large",
                  "unsupported_media_type",
                  "invalid_content_length",
                  "invalid_json",
                  "invalid_body",
                  "read_only_key",
                  "feedback_limit_reached",
                  "feedback_unavailable",
                  "internal_error"
                ]
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "V2Status": {
        "type": "object",
        "properties": {
          "tenant_id": {
            "type": "string"
          },
          "observations": {
            "type": "integer"
          },
          "text_observations": {
            "type": "integer"
          },
          "cold_start": {
            "type": "boolean"
          },
          "alarm": {
            "type": "boolean"
          },
          "closed_codes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "V2Codes": {
        "type": "object",
        "required": [
          "codes"
        ],
        "properties": {
          "codes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "V2Forget": {
        "type": "object",
        "required": [
          "field",
          "value"
        ],
        "properties": {
          "field": {
            "type": "string"
          },
          "value": {
            "type": [
              "string",
              "number"
            ]
          }
        }
      },
      "V2JobAccepted": {
        "type": "object",
        "properties": {
          "job_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "accepted"
            ]
          },
          "status_url": {
            "type": "string",
            "description": "Relative URL to poll, /v2/tenants/{id}/jobs/{job_id}."
          }
        }
      },
      "V2Job": {
        "type": "object",
        "properties": {
          "job_id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "rollback",
              "forget"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "done",
              "failed"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "finished_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "result": {
            "type": "object",
            "description": "When done: {\"status\": \"rolled_back\", \"observations\": n} or {\"status\": \"forgotten\", \"removed\": n}."
          },
          "error": {
            "type": "object",
            "description": "When failed: {\"code\", \"message\"} (same shape as other errors). The learning-cap quota taken at acceptance is given back."
          }
        }
      },
      "V2FeedbackRequest": {
        "type": "object",
        "required": [
          "type",
          "text"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "bug",
              "feature",
              "accuracy"
            ]
          },
          "text": {
            "type": "string",
            "maxLength": 2000,
            "description": "Do not write invoice content. National ids (TCKN, VKN), IBAN, card numbers and e-mail addresses are masked automatically before storing."
          },
          "item_id": {
            "type": "string",
            "description": "Optional item id the note is about (stored only as a short hash)."
          }
        }
      }
    },
    "responses": {
      "Hata400": {
        "description": "Geçersiz istek gövdesi veya parametre",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/HataYaniti"
            }
          }
        }
      },
      "Hata401": {
        "description": "Eksik veya geçersiz Bearer API anahtarı",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/HataYaniti"
            }
          }
        }
      },
      "Hata403": {
        "description": "Başka kiracıya erişim veya süresi dolmuş Sandbox anahtarı",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/HataYaniti"
            }
          }
        }
      },
      "Hata413": {
        "description": "İstek gövdesi 1 MiB sınırını aşıyor",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/HataYaniti"
            }
          }
        }
      },
      "Hata415": {
        "description": "Content-Type application/json değil",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/HataYaniti"
            }
          }
        }
      },
      "Hata429": {
        "description": "Sandbox çağrı kotası doldu",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/HataYaniti"
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "paths": {
    "/v1/saglik": {
      "get": {
        "summary": "Sunucu sağlık kontrolü",
        "security": [],
        "responses": {
          "200": {
            "description": "Sunucu çalışıyor",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "durum": {
                      "type": "string",
                      "example": "tamam"
                    },
                    "kiraci_sayisi": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/kiracilar/{id}/tahmin": {
      "post": {
        "summary": "Yapısal (+ opsiyonel kısa serbest metin) karar tahmini",
        "parameters": [
          {
            "$ref": "#/components/parameters/KiraciId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TahminIstegi"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Tahmin sonucu",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TahminYaniti"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Hata400"
          },
          "401": {
            "$ref": "#/components/responses/Hata401"
          },
          "403": {
            "$ref": "#/components/responses/Hata403"
          },
          "413": {
            "$ref": "#/components/responses/Hata413"
          },
          "415": {
            "$ref": "#/components/responses/Hata415"
          },
          "429": {
            "$ref": "#/components/responses/Hata429"
          }
        }
      }
    },
    "/v1/kiracilar/{id}/ogren": {
      "post": {
        "summary": "İnsan doğrulamalı tek seferde öğrenme",
        "parameters": [
          {
            "$ref": "#/components/parameters/KiraciId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OgrenIstegi"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Kayıt öğrenildi",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "durum": {
                      "type": "string"
                    },
                    "gozlem": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Hata400"
          },
          "401": {
            "$ref": "#/components/responses/Hata401"
          },
          "403": {
            "$ref": "#/components/responses/Hata403"
          },
          "413": {
            "$ref": "#/components/responses/Hata413"
          },
          "415": {
            "$ref": "#/components/responses/Hata415"
          },
          "429": {
            "$ref": "#/components/responses/Hata429"
          }
        }
      }
    },
    "/v1/kiracilar/{id}/geri-al": {
      "post": {
        "summary": "Tekil gözlemi iz bırakmadan kesin geri alma (Exact Unlearning)",
        "parameters": [
          {
            "$ref": "#/components/parameters/KiraciId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OgrenIstegi"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Kayıt geri alındı"
          },
          "400": {
            "$ref": "#/components/responses/Hata400"
          },
          "401": {
            "$ref": "#/components/responses/Hata401"
          },
          "403": {
            "$ref": "#/components/responses/Hata403"
          },
          "202": {
            "description": "Arka plana alındı (yalnız arka_plan: true ile)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "is_id": {
                      "type": "string"
                    },
                    "durum": {
                      "type": "string",
                      "enum": [
                        "kabul_edildi"
                      ]
                    },
                    "durum_url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Varsayılan eşzamanlıdır. Büyük kiracılarda gövdeye \"arka_plan\": true ekleyin: 202 ve is_id döner, durumu GET /v1/kiracilar/{id}/isler/{is_id} ile sorun. Etki iş bitince başlar; arada tahminler eski durumu kullanır."
      }
    },
    "/v1/kiracilar/{id}/unut": {
      "post": {
        "summary": "Bir (alan, değer) çiftini eksiksiz unutma",
        "parameters": [
          {
            "$ref": "#/components/parameters/KiraciId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UnutIstegi"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "İlgili kayıtlar unutuldu"
          },
          "400": {
            "$ref": "#/components/responses/Hata400"
          },
          "401": {
            "$ref": "#/components/responses/Hata401"
          },
          "403": {
            "$ref": "#/components/responses/Hata403"
          },
          "202": {
            "description": "Arka plana alındı (yalnız arka_plan: true ile)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "is_id": {
                      "type": "string"
                    },
                    "durum": {
                      "type": "string",
                      "enum": [
                        "kabul_edildi"
                      ]
                    },
                    "durum_url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Varsayılan eşzamanlıdır. Büyük kiracılarda gövdeye \"arka_plan\": true ekleyin: 202 ve is_id döner, durumu GET /v1/kiracilar/{id}/isler/{is_id} ile sorun. Etki iş bitince başlar; arada tahminler eski durumu kullanır."
      }
    },
    "/v1/kiracilar/{id}/kod-kapat": {
      "post": {
        "summary": "Eski veya yürürlükten kalkan kodu geçersiz listesine ekleme",
        "parameters": [
          {
            "$ref": "#/components/parameters/KiraciId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KodListesiIstegi"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Kodlar kapatıldı"
          },
          "400": {
            "$ref": "#/components/responses/Hata400"
          },
          "401": {
            "$ref": "#/components/responses/Hata401"
          },
          "403": {
            "$ref": "#/components/responses/Hata403"
          }
        }
      }
    },
    "/v1/kiracilar/{id}/kod-ac": {
      "post": {
        "summary": "Kodu geçersiz listesinden çıkarma",
        "parameters": [
          {
            "$ref": "#/components/parameters/KiraciId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KodListesiIstegi"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Kodlar açıldı"
          },
          "400": {
            "$ref": "#/components/responses/Hata400"
          },
          "401": {
            "$ref": "#/components/responses/Hata401"
          },
          "403": {
            "$ref": "#/components/responses/Hata403"
          }
        }
      }
    },
    "/v1/kiracilar/{id}/tasima-onerileri": {
      "get": {
        "summary": "Kapanan kodlar için hedef kod taşıma önerileri",
        "parameters": [
          {
            "$ref": "#/components/parameters/KiraciId"
          },
          {
            "name": "en_az",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 5
            }
          },
          {
            "name": "pay",
            "in": "query",
            "schema": {
              "type": "number",
              "default": 0.8
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Taşıma önerileri listesi"
          },
          "401": {
            "$ref": "#/components/responses/Hata401"
          },
          "403": {
            "$ref": "#/components/responses/Hata403"
          }
        }
      }
    },
    "/v1/kiracilar/{id}/tasima-kaniti": {
      "post": {
        "summary": "Eski → yeni kod taşıma kanıt özeti",
        "parameters": [
          {
            "$ref": "#/components/parameters/KiraciId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TasimaKanitiIstegi"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Kanıt özeti"
          },
          "400": {
            "$ref": "#/components/responses/Hata400"
          },
          "401": {
            "$ref": "#/components/responses/Hata401"
          },
          "403": {
            "$ref": "#/components/responses/Hata403"
          }
        }
      }
    },
    "/v1/kiracilar/{id}/tasi": {
      "post": {
        "summary": "Onaylı kod taşıma (onay: true zorunlu)",
        "parameters": [
          {
            "$ref": "#/components/parameters/KiraciId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TasiIstegi"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Kodlar taşındı"
          },
          "400": {
            "$ref": "#/components/responses/Hata400"
          },
          "401": {
            "$ref": "#/components/responses/Hata401"
          },
          "403": {
            "$ref": "#/components/responses/Hata403"
          }
        }
      }
    },
    "/v1/kiracilar/{id}/durum": {
      "get": {
        "summary": "Kiracı özeti, sütun süzgeci ve güvenlik freni durumu",
        "parameters": [
          {
            "$ref": "#/components/parameters/KiraciId"
          }
        ],
        "responses": {
          "200": {
            "description": "Kiracı durumu"
          },
          "401": {
            "$ref": "#/components/responses/Hata401"
          },
          "403": {
            "$ref": "#/components/responses/Hata403"
          }
        }
      }
    },
    "/v1/kiracilar/{id}/kaydet": {
      "post": {
        "summary": "Kiracı durumunu atomik olarak diske kaydetme",
        "parameters": [
          {
            "$ref": "#/components/parameters/KiraciId"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Diske kaydedildi"
          },
          "401": {
            "$ref": "#/components/responses/Hata401"
          },
          "403": {
            "$ref": "#/components/responses/Hata403"
          }
        }
      }
    },
    "/v1/kiracilar/{id}/tahmin-toplu": {
      "post": {
        "summary": "Toplu karar (en çok 1000 kayıt; her kayıt karar kotasından düşer)",
        "parameters": [
          {
            "$ref": "#/components/parameters/KiraciId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TopluTahminIstegi"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Kayıtlar işlendi",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TopluYanit"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Hata400"
          },
          "401": {
            "$ref": "#/components/responses/Hata401"
          },
          "403": {
            "$ref": "#/components/responses/Hata403"
          },
          "413": {
            "$ref": "#/components/responses/Hata413"
          },
          "415": {
            "$ref": "#/components/responses/Hata415"
          },
          "429": {
            "$ref": "#/components/responses/Hata429"
          }
        }
      }
    },
    "/v1/kiracilar/{id}/ogren-toplu": {
      "post": {
        "summary": "Toplu öğretme (en çok 1000 kayıt; geçmiş veriyi yüklemek için, ticari kotayı yemez)",
        "parameters": [
          {
            "$ref": "#/components/parameters/KiraciId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TopluOgrenIstegi"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Kayıtlar işlendi",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TopluYanit"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Hata400"
          },
          "401": {
            "$ref": "#/components/responses/Hata401"
          },
          "403": {
            "$ref": "#/components/responses/Hata403"
          },
          "413": {
            "$ref": "#/components/responses/Hata413"
          },
          "415": {
            "$ref": "#/components/responses/Hata415"
          },
          "429": {
            "$ref": "#/components/responses/Hata429"
          }
        }
      }
    },
    "/v2/health": {
      "get": {
        "tags": [
          "v2"
        ],
        "summary": "Health check",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v2/tenants/{id}/predict": {
      "post": {
        "tags": [
          "v2"
        ],
        "summary": "Predict a code for one record. Uses 1 decision. (read-only keys allowed)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Tenant id"
          },
          {
            "name": "X-Becda-Client",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9._-]{1,32}/[0-9A-Za-z._-]{1,16}$"
            },
            "description": "Integration name and version, e.g. odoo-18/1.0. Missing or invalid values are counted as \"diger\"."
          }
        ],
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2PredictResponse"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "413": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/V2PredictRequest"
              }
            }
          }
        }
      }
    },
    "/v2/tenants/{id}/predict-batch": {
      "post": {
        "tags": [
          "v2"
        ],
        "summary": "Predict up to 1000 records. Uses 1 decision per record. (read-only keys allowed)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Tenant id"
          },
          {
            "name": "X-Becda-Client",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9._-]{1,32}/[0-9A-Za-z._-]{1,16}$"
            },
            "description": "Integration name and version, e.g. odoo-18/1.0. Missing or invalid values are counted as \"diger\"."
          }
        ],
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2BatchResponse"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "413": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/V2BatchPredictRequest"
              }
            }
          }
        }
      }
    },
    "/v2/tenants/{id}/learn": {
      "post": {
        "tags": [
          "v2"
        ],
        "summary": "Teach a person-approved code. Does not use decision quota.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Tenant id"
          },
          {
            "name": "X-Becda-Client",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9._-]{1,32}/[0-9A-Za-z._-]{1,16}$"
            },
            "description": "Integration name and version, e.g. odoo-18/1.0. Missing or invalid values are counted as \"diger\"."
          }
        ],
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "observations": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "413": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/V2LearnRequest"
              }
            }
          }
        }
      }
    },
    "/v2/tenants/{id}/learn-batch": {
      "post": {
        "tags": [
          "v2"
        ],
        "summary": "Teach up to 1000 past records (history upload). Does not use decision quota.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Tenant id"
          },
          {
            "name": "X-Becda-Client",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9._-]{1,32}/[0-9A-Za-z._-]{1,16}$"
            },
            "description": "Integration name and version, e.g. odoo-18/1.0. Missing or invalid values are counted as \"diger\"."
          }
        ],
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2BatchResponse"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "413": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/V2BatchLearnRequest"
              }
            }
          }
        }
      }
    },
    "/v2/tenants/{id}/rollback": {
      "post": {
        "tags": [
          "v2"
        ],
        "summary": "Undo one wrongly taught record exactly, without retraining. Asynchronous: returns a job; the undo takes effect when the job is done.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Tenant id"
          },
          {
            "name": "X-Becda-Client",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9._-]{1,32}/[0-9A-Za-z._-]{1,16}$"
            },
            "description": "Integration name and version, e.g. odoo-18/1.0. Missing or invalid values are counted as \"diger\"."
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional. The same key for the same tenant returns the same job and uses the quota once."
          }
        ],
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted. Poll status_url.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2JobAccepted"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "413": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/V2LearnRequest"
              }
            }
          }
        }
      }
    },
    "/v2/tenants/{id}/forget": {
      "post": {
        "tags": [
          "v2"
        ],
        "summary": "Remove every record that carries a value (e.g. a deletion request). Asynchronous: returns a job; the removal takes effect when the job is done.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Tenant id"
          },
          {
            "name": "X-Becda-Client",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9._-]{1,32}/[0-9A-Za-z._-]{1,16}$"
            },
            "description": "Integration name and version, e.g. odoo-18/1.0. Missing or invalid values are counted as \"diger\"."
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional. The same key for the same tenant returns the same job and uses the quota once."
          }
        ],
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted. Poll status_url.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2JobAccepted"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "413": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/V2Forget"
              }
            }
          }
        }
      }
    },
    "/v2/tenants/{id}/jobs/{job_id}": {
      "get": {
        "tags": [
          "v2"
        ],
        "summary": "Status of a rollback or forget job (read-only keys allowed). Jobs are kept for 24 hours.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Tenant id"
          },
          {
            "name": "X-Becda-Client",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9._-]{1,32}/[0-9A-Za-z._-]{1,16}$"
            },
            "description": "Integration name and version, e.g. odoo-18/1.0. Missing or invalid values are counted as \"diger\"."
          },
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Job"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          }
        }
      }
    },
    "/v2/tenants/{id}/close-codes": {
      "post": {
        "tags": [
          "v2"
        ],
        "summary": "Close codes: they are no longer approved automatically.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Tenant id"
          },
          {
            "name": "X-Becda-Client",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9._-]{1,32}/[0-9A-Za-z._-]{1,16}$"
            },
            "description": "Integration name and version, e.g. odoo-18/1.0. Missing or invalid values are counted as \"diger\"."
          }
        ],
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "added": {
                      "type": "integer"
                    },
                    "closed_codes": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "413": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/V2Codes"
              }
            }
          }
        }
      }
    },
    "/v2/tenants/{id}/open-codes": {
      "post": {
        "tags": [
          "v2"
        ],
        "summary": "Re-open closed codes.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Tenant id"
          },
          {
            "name": "X-Becda-Client",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9._-]{1,32}/[0-9A-Za-z._-]{1,16}$"
            },
            "description": "Integration name and version, e.g. odoo-18/1.0. Missing or invalid values are counted as \"diger\"."
          }
        ],
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "removed": {
                      "type": "integer"
                    },
                    "closed_codes": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "413": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/V2Codes"
              }
            }
          }
        }
      }
    },
    "/v2/tenants/{id}/status": {
      "get": {
        "tags": [
          "v2"
        ],
        "summary": "Tenant status. (read-only keys allowed)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Tenant id"
          },
          {
            "name": "X-Becda-Client",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9._-]{1,32}/[0-9A-Za-z._-]{1,16}$"
            },
            "description": "Integration name and version, e.g. odoo-18/1.0. Missing or invalid values are counted as \"diger\"."
          }
        ],
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Status"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          }
        }
      }
    },
    "/v2/tenants/{id}/feedback": {
      "post": {
        "tags": [
          "v2"
        ],
        "summary": "Send a bug report, feature request or accuracy note. Uses no quota. (read-only keys allowed)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Tenant id"
          },
          {
            "name": "X-Becda-Client",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9._-]{1,32}/[0-9A-Za-z._-]{1,16}$"
            },
            "description": "Integration name and version, e.g. odoo-18/1.0. Missing or invalid values are counted as \"diger\"."
          }
        ],
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "413": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "integer"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "new"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/V2FeedbackRequest"
              }
            }
          }
        }
      }
    },
    "/v2/tenants/{id}/whoami": {
      "get": {
        "tags": [
          "v2"
        ],
        "summary": "Which tenant this key belongs to and whether it is read-only. Uses no quota. (read-only keys allowed)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Tenant id"
          },
          {
            "name": "X-Becda-Client",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9._-]{1,32}/[0-9A-Za-z._-]{1,16}$"
            },
            "description": "Integration name and version, e.g. odoo-18/1.0. Missing or invalid values are counted as \"diger\"."
          }
        ],
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tenant_id": {
                      "type": "string"
                    },
                    "read_only": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/kiracilar/{id}/isler/{is_id}": {
      "get": {
        "summary": "Arka plan işinin durumu (salt okunur anahtar okuyabilir; işler 24 saat saklanır)",
        "parameters": [
          {
            "$ref": "#/components/parameters/KiraciId"
          },
          {
            "name": "is_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "durum: kuyrukta | calisiyor | bitti (sonuc) | basarisiz (kod, hata)"
          },
          "401": {
            "$ref": "#/components/responses/Hata401"
          },
          "404": {
            "description": "İş yok ya da başka kiracıya ait"
          }
        }
      }
    },
    "/v1/kiracilar/{id}/kural-izleme": {
      "get": {
        "tags": [
          "v1"
        ],
        "summary": "ZDR uyumlu canlı Karar Kuralları sayaçları ve son 100 karar akışı (kota harcamaz, salt okunur anahtar serbest)",
        "parameters": [
          {
            "$ref": "#/components/parameters/KiraciId"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 50,
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Satır bazlı kural takılma sayaçları ve içerik içermeyen son olaylar"
          },
          "401": {
            "$ref": "#/components/responses/Hata401"
          }
        }
      }
    },
    "/v2/tenants/{id}/rules": {
      "get": {
        "tags": [
          "v2"
        ],
        "summary": "Read active company/policy decision rules (pre-rules and post-rules) and plain-language summaries. Uses no quota. (read-only keys allowed)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Active rule version, pre/post JDM graphs, and plain-language summaries"
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/v2/tenants/{id}/rules/test": {
      "post": {
        "tags": [
          "v2"
        ],
        "summary": "Dry-run current or proposed pre/post decision rules against tenant memory with zero quota cost and zero side effects. (read-only keys allowed)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Step-by-step simulation trace (pre_result, becda_result, post_result, final_decision)"
          },
          "400": {
            "description": "Invalid JDM rule or request body"
          }
        }
      }
    },
    "/v2/tenants/{id}/rules/draft": {
      "post": {
        "tags": [
          "v2"
        ],
        "summary": "Validate and save pre/post decision rules as a DRAFT only (never modifies live traffic; a person publishes from Portal > Karar Kuralları). Full key required.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Draft validated and saved with plain-language summary"
          },
          "400": {
            "description": "Rule validation failed (e.g. blocked functionNode or invalid schema)"
          },
          "403": {
            "description": "Read-only key cannot save drafts"
          }
        }
      }
    },
    "/v2/tenants/{id}/rules-telemetry": {
      "get": {
        "tags": [
          "v2"
        ],
        "summary": "ZDR-safe live decision rule hit counts and last 100 events (no invoice content stored). Uses no quota. (read-only keys allowed)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 50,
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Summary counts, per-row hit counters, and content-free recent events"
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    }
  }
}
