{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/pyai-com/json-schema/pyai-com-telephony-call-schema.json",
  "title": "TelephonyCall",
  "x-generated": "2026-11-22",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/pyai-com-openapi.json#/components/schemas/TelephonyCall",
  "type": "object",
  "properties": {
    "version": {
      "type": "integer"
    },
    "project_id": {
      "type": "string"
    },
    "direction": {
      "type": "string",
      "enum": [
        "inbound",
        "outbound"
      ]
    },
    "from": {
      "type": "string"
    },
    "destination_number_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "admission_mode": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "client",
        "platform",
        null
      ]
    },
    "admission_status": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "pending",
        "accept",
        "reject",
        "expired",
        null
      ]
    },
    "admission_expires_at": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Original pre-answer admission deadline, Unix ms."
    },
    "max_duration_seconds": {
      "type": [
        "integer",
        "null"
      ]
    },
    "client_reference": {
      "type": [
        "string",
        "null"
      ]
    },
    "agent_release_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "stop_requested": {
      "type": "boolean"
    },
    "object": {
      "type": "string"
    },
    "id": {
      "type": "string"
    },
    "from_number_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "to": {
      "type": "string"
    },
    "dialing_mode": {
      "type": "string",
      "const": "parallel",
      "description": "Present for a parallel human-call group."
    },
    "destinations": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "minItems": 2,
      "maxItems": 4
    },
    "connected_to": {
      "type": [
        "string",
        "null"
      ],
      "description": "Destination confirmed by the group connection result; null while unresolved."
    },
    "lines": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "to",
          "status",
          "duration_seconds"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "to": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "queued",
              "ringing",
              "answered",
              "completed",
              "failed",
              "canceled"
            ]
          },
          "duration_seconds": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "Verified terminal phone-leg duration; null until available."
          }
        }
      }
    },
    "agent_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "call_type": {
      "type": "string",
      "enum": [
        "human"
      ]
    },
    "user_id": {
      "type": "string"
    },
    "forwarding": {
      "type": "object",
      "required": [
        "to",
        "status"
      ],
      "properties": {
        "to": {
          "type": [
            "string",
            "null"
          ]
        },
        "menu": {
          "type": "object",
          "required": [
            "kind",
            "status",
            "choice_id"
          ],
          "properties": {
            "kind": {
              "type": "string",
              "const": "keypad"
            },
            "status": {
              "type": "string",
              "enum": [
                "pending",
                "selected",
                "rejected"
              ]
            },
            "choice_id": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        },
        "status": {
          "type": "string",
          "enum": [
            "waiting",
            "claimed",
            "unknown",
            "acknowledged",
            "canceled"
          ]
        }
      }
    },
    "transfer_enabled": {
      "type": "boolean"
    },
    "held": {
      "type": "boolean",
      "description": "Confirmed hold state of the connected human caller."
    },
    "hold_pending": {
      "type": "boolean",
      "description": "A caller hold/resume effect awaits confirmation."
    },
    "transfers": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "mode",
          "status",
          "to"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "mode": {
            "type": "string",
            "enum": [
              "warm",
              "cold"
            ]
          },
          "to": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "holding",
              "dialing",
              "ready",
              "completing",
              "canceling",
              "completed",
              "canceled",
              "failed"
            ]
          }
        }
      }
    },
    "use_case": {
      "type": "string",
      "enum": [
        "transactional",
        "support",
        "sales",
        "collections",
        "survey"
      ]
    },
    "routing_profile": {
      "type": "string",
      "enum": [
        "quality_first",
        "balanced",
        "cost_optimized"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "dispatching",
        "ringing",
        "in_progress",
        "completed",
        "failed",
        "canceled",
        "dispatch_unknown"
      ]
    },
    "attempt_count": {
      "type": "integer",
      "minimum": 0,
      "maximum": 3
    },
    "max_attempts": {
      "type": "integer",
      "minimum": 1,
      "maximum": 3
    },
    "failure_reason": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "network_unavailable",
        "congestion",
        "timeout",
        "no_answer",
        "busy",
        "rejected",
        "invalid_number",
        "identity_blocked",
        "compliance_blocked",
        "unknown",
        null
      ]
    },
    "created_at": {
      "type": "integer",
      "description": "Unix ms."
    },
    "updated_at": {
      "type": "integer",
      "description": "Unix ms."
    },
    "answered_at": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Unix ms."
    },
    "ended_at": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Unix ms."
    },
    "artifacts": {
      "type": "object",
      "description": "Post-call artifact and billing readiness. Included on the single-call detail response. Artifact readiness and network billing readiness are independent; media_not_started means the terminal call never acquired a media session.",
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "pending",
            "ready",
            "unavailable"
          ]
        },
        "omni_call_id": {
          "type": "string"
        },
        "recording": {
          "type": "object",
          "properties": {
            "status": {
              "type": "string"
            },
            "reason": {
              "type": [
                "string",
                "null"
              ]
            },
            "resource": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        },
        "transcript": {
          "type": "object",
          "properties": {
            "status": {
              "type": "string"
            },
            "reason": {
              "type": [
                "string",
                "null"
              ]
            },
            "text": {
              "type": [
                "string",
                "null"
              ],
              "description": "Speaker-labelled transcript text when available inline."
            },
            "resource": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        },
        "ai_usage": {
          "type": "object",
          "description": "AI usage joined to the gateway ledger for every media session of this call. Zero is final only when durable admission proves that no media session started; otherwise pending until all evidence is present.",
          "properties": {
            "status": {
              "type": "string",
              "enum": [
                "pending",
                "recorded"
              ]
            },
            "meter": {
              "type": "string"
            },
            "units": {
              "type": "number"
            },
            "billable_units": {
              "type": "number"
            }
          }
        },
        "usage": {
          "type": "object",
          "properties": {
            "status": {
              "type": "string",
              "enum": [
                "pending",
                "recorded"
              ]
            },
            "meter": {
              "type": "string"
            },
            "units": {
              "type": "number"
            },
            "billable": {
              "type": "boolean"
            }
          }
        }
      }
    }
  }
}