{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.twilio.com/docs/schemas/twilio/call.json",
  "title": "Twilio Call",
  "description": "Represents a voice call made to or from a Twilio account, including call status, duration, pricing, and related metadata.",
  "type": "object",
  "properties": {
    "sid": {
      "type": "string",
      "pattern": "^CA[0-9a-fA-F]{32}$",
      "description": "Unique 34-character identifier for the call"
    },
    "account_sid": {
      "type": "string",
      "pattern": "^AC[0-9a-fA-F]{32}$",
      "description": "SID of the Twilio account that created the call"
    },
    "parent_call_sid": {
      "type": ["string", "null"],
      "pattern": "^CA[0-9a-fA-F]{32}$",
      "description": "SID of the parent call if this is a child call leg"
    },
    "to": {
      "type": "string",
      "description": "Phone number, SIP URI, or client identifier that received the call"
    },
    "to_formatted": {
      "type": "string",
      "description": "Formatted version of the To number"
    },
    "from": {
      "type": "string",
      "description": "Phone number or client identifier that initiated the call"
    },
    "from_formatted": {
      "type": "string",
      "description": "Formatted version of the From number"
    },
    "phone_number_sid": {
      "type": ["string", "null"],
      "pattern": "^PN[0-9a-fA-F]{32}$",
      "description": "SID of the Twilio phone number used"
    },
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "ringing",
        "in-progress",
        "canceled",
        "completed",
        "failed",
        "busy",
        "no-answer"
      ],
      "description": "Current status of the call"
    },
    "direction": {
      "type": "string",
      "enum": [
        "inbound",
        "outbound-api",
        "outbound-dial"
      ],
      "description": "Direction of the call"
    },
    "price": {
      "type": ["string", "null"],
      "description": "Price of the call in the account currency"
    },
    "price_unit": {
      "type": "string",
      "description": "ISO 4217 currency code"
    },
    "duration": {
      "type": ["string", "null"],
      "description": "Duration of the call in seconds"
    },
    "start_time": {
      "type": ["string", "null"],
      "format": "date-time",
      "description": "ISO 8601 timestamp when the call started"
    },
    "end_time": {
      "type": ["string", "null"],
      "format": "date-time",
      "description": "ISO 8601 timestamp when the call ended"
    },
    "answered_by": {
      "type": ["string", "null"],
      "enum": ["human", "machine", null],
      "description": "Whether the call was answered by a human or machine"
    },
    "caller_name": {
      "type": ["string", "null"],
      "description": "Caller name from CNAM lookup"
    },
    "forwarded_from": {
      "type": ["string", "null"],
      "description": "Number that forwarded the inbound call"
    },
    "group_sid": {
      "type": ["string", "null"],
      "description": "SID identifying the call group"
    },
    "queue_time": {
      "type": ["string", "null"],
      "description": "Time the call spent in queue in milliseconds"
    },
    "trunk_sid": {
      "type": ["string", "null"],
      "description": "SID of the SIP trunk used for the call"
    },
    "date_created": {
      "type": "string",
      "format": "date-time",
      "description": "ISO 8601 timestamp when the resource was created"
    },
    "date_updated": {
      "type": "string",
      "format": "date-time",
      "description": "ISO 8601 timestamp when the resource was last updated"
    },
    "api_version": {
      "type": "string",
      "description": "Twilio API version used"
    },
    "uri": {
      "type": "string",
      "description": "Relative URI for this call resource"
    },
    "subresource_uris": {
      "type": "object",
      "description": "URIs of related subresources",
      "properties": {
        "recordings": {
          "type": "string"
        },
        "notifications": {
          "type": "string"
        },
        "feedback": {
          "type": "string"
        },
        "feedback_summaries": {
          "type": "string"
        },
        "payments": {
          "type": "string"
        },
        "events": {
          "type": "string"
        }
      }
    }
  },
  "required": ["sid", "account_sid", "to", "from", "status", "direction"]
}
