{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/call2me-app/json-schema/call2me-app-call-schema.json",
  "title": "Call",
  "description": "Complete call record.",
  "x-generated": "2026-11-03",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/call2me-app-openapi.json#/components/schemas/Call",
  "properties": {
    "call_id": {
      "type": "string",
      "pattern": "^(call|demo|test|interp|bridge)_[a-f0-9]{8,24}$",
      "title": "Call Id",
      "description": "Unique call identifier"
    },
    "agent_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Agent Id",
      "description": "Agent used for this call (tercüman/köprü aramalarında yok)"
    },
    "call_status": {
      "type": "string",
      "enum": [
        "pending",
        "ringing",
        "in_progress",
        "completed",
        "failed",
        "no_answer",
        "busy",
        "transferred",
        "ended"
      ],
      "title": "Call Status",
      "description": "Current call status"
    },
    "call_type": {
      "type": "string",
      "enum": [
        "inbound",
        "outbound",
        "sip_call",
        "web_call",
        "interpreter",
        "phone_call",
        "phone"
      ],
      "title": "Call Type",
      "description": "Call direction type"
    },
    "direction": {
      "type": "string",
      "enum": [
        "inbound",
        "outbound",
        "web",
        "web_bridge"
      ],
      "title": "Direction",
      "description": "Call direction"
    },
    "from_number": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "From Number",
      "description": "Caller phone number"
    },
    "to_number": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "To Number",
      "description": "Callee phone number"
    },
    "start_timestamp": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Start Timestamp",
      "description": "Unix timestamp in milliseconds when call started"
    },
    "end_timestamp": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "End Timestamp",
      "description": "Unix timestamp in milliseconds when call ended"
    },
    "duration_ms": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Duration Ms",
      "description": "Call duration in milliseconds"
    },
    "transcript": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Transcript",
      "description": "Full transcript as text"
    },
    "transcript_object": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/TranscriptTurn"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Transcript Object",
      "description": "Structured transcript"
    },
    "recording_url": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Recording Url",
      "description": "URL to call recording"
    },
    "disconnection_reason": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 500
        },
        {
          "type": "null"
        }
      ],
      "title": "Disconnection Reason",
      "description": "Reason the call ended (sabit kod ya da ajanın açıklaması)"
    },
    "call_analysis": {
      "anyOf": [
        {
          "$ref": "#/$defs/CallAnalysis"
        },
        {
          "type": "null"
        }
      ],
      "description": "Post-call analysis"
    },
    "metadata": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Metadata",
      "description": "Custom metadata"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "title": "Created At",
      "description": "Record creation time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "title": "Updated At",
      "description": "Last update time"
    }
  },
  "type": "object",
  "required": [
    "call_id",
    "call_status",
    "call_type",
    "direction"
  ],
  "$defs": {
    "CallAnalysis": {
      "properties": {
        "call_successful": {
          "type": "boolean",
          "title": "Call Successful",
          "description": "Whether the call achieved its goal"
        },
        "call_summary": {
          "type": "string",
          "title": "Call Summary",
          "description": "AI-generated summary of the call"
        },
        "user_sentiment": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "positive",
                "neutral",
                "negative"
              ]
            },
            {
              "type": "null"
            }
          ],
          "title": "User Sentiment",
          "description": "Overall user sentiment"
        },
        "custom_analysis_data": {
          "anyOf": [
            {
              "additionalProperties": true,
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Custom Analysis Data",
          "description": "Custom analysis results"
        }
      },
      "type": "object",
      "required": [
        "call_successful",
        "call_summary"
      ],
      "title": "CallAnalysis",
      "description": "Post-call analysis results."
    },
    "TranscriptTurn": {
      "properties": {
        "role": {
          "type": "string",
          "enum": [
            "agent",
            "user"
          ],
          "title": "Role",
          "description": "Speaker role"
        },
        "text": {
          "type": "string",
          "title": "Text",
          "description": "Spoken text (canlı veride `text` anahtarı)"
        },
        "timestamp": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Timestamp",
          "description": "ISO 8601 timestamp"
        }
      },
      "type": "object",
      "required": [
        "role",
        "text"
      ],
      "title": "TranscriptTurn",
      "description": "Single turn in a conversation transcript.\n\nCANLI VERİ `text` ANAHTARI KULLANIYOR (ölçüldü 2 Eki 2026: incelenen 400\ntranskript turunun 400'ünde `role` + `text`, `content` HİÇ YOK). Model\n`content` bekliyordu, dolayısıyla transkripti olan HİÇBİR arama\n`CallRepository.get()` ile okunamıyordu."
    }
  }
}