{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/ringkit-com/json-schema/ringkit-com-call-schema.json",
  "title": "Call",
  "x-generated": "2026-12-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/ringkit-com-openapi.json#/components/schemas/Call",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^call_[0-9a-z]{8,32}$"
    },
    "businessId": {
      "type": "string",
      "pattern": "^biz_[0-9a-z]{8,32}$"
    },
    "direction": {
      "type": "string",
      "enum": [
        "inbound",
        "outbound"
      ]
    },
    "from": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^\\+[1-9]\\d{6,14}$"
        },
        {
          "type": "string",
          "const": "anonymous"
        }
      ]
    },
    "to": {
      "type": "string",
      "pattern": "^\\+[1-9]\\d{6,14}$"
    },
    "status": {
      "type": "string",
      "enum": [
        "ringing",
        "in_progress",
        "completed",
        "failed",
        "rejected"
      ]
    },
    "provider": {
      "type": "string"
    },
    "providerCallId": {
      "type": "string"
    },
    "startedAt": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
    },
    "answeredAt": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
    },
    "endedAt": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
    },
    "endReason": {
      "type": "string",
      "enum": [
        "caller_hangup",
        "agent_hangup",
        "transferred",
        "no_balance",
        "spam",
        "error",
        "voicemail"
      ]
    },
    "segments": {
      "default": [],
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "handler": {
            "type": "string",
            "enum": [
              "ai",
              "human"
            ]
          },
          "agentId": {
            "type": "string",
            "pattern": "^agt_[0-9a-z]{8,32}$"
          },
          "startedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
          },
          "endedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
          }
        },
        "required": [
          "handler",
          "startedAt"
        ],
        "additionalProperties": false
      }
    },
    "summary": {
      "type": "object",
      "properties": {
        "intent": {
          "type": "string",
          "minLength": 1,
          "maxLength": 60
        },
        "outcome": {
          "type": "string",
          "enum": [
            "answered",
            "message_taken",
            "transferred",
            "booked",
            "callback_scheduled",
            "spam",
            "abandoned",
            "unresolved"
          ]
        },
        "callerName": {
          "type": "string"
        },
        "summary": {
          "type": "string",
          "maxLength": 1500
        },
        "message": {
          "type": "object",
          "properties": {
            "callerName": {
              "type": "string"
            },
            "callbackNumber": {
              "type": "string",
              "pattern": "^\\+[1-9]\\d{6,14}$"
            },
            "message": {
              "type": "string"
            },
            "urgency": {
              "default": "normal",
              "type": "string",
              "enum": [
                "low",
                "normal",
                "high"
              ]
            }
          },
          "required": [
            "message",
            "urgency"
          ],
          "additionalProperties": false
        },
        "followUpNeeded": {
          "default": false,
          "type": "boolean"
        },
        "sentiment": {
          "type": "string",
          "enum": [
            "positive",
            "neutral",
            "negative"
          ]
        }
      },
      "required": [
        "intent",
        "outcome",
        "summary",
        "followUpNeeded"
      ],
      "additionalProperties": false
    },
    "recordingUrl": {
      "type": "string"
    },
    "spamScore": {
      "type": "number",
      "minimum": 0,
      "maximum": 1
    },
    "billedCents": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "knowledgeHash": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "businessId",
    "direction",
    "from",
    "to",
    "status",
    "provider",
    "providerCallId",
    "startedAt",
    "segments"
  ],
  "additionalProperties": false
}