{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/simple-ai/json-schema/simple-ai-interaction-details-response-schema.json",
  "title": "InteractionDetailsResponse",
  "x-generated": "2026-10-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/simple-ai-openapi.json#/components/schemas/InteractionDetailsResponse",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "title": "Id"
    },
    "type": {
      "type": "string",
      "enum": [
        "call",
        "conversation",
        "email",
        "sms",
        "external_channel"
      ],
      "title": "Type",
      "description": "Identifies whether the interaction is a native call/conversation or an external-channel interaction."
    },
    "modality": {
      "anyOf": [
        {
          "$ref": "#/$defs/ModalityEnum"
        },
        {
          "type": "null"
        }
      ],
      "description": "Native interactions return `voice` or `text`. External-channel interactions return `null`."
    },
    "language": {
      "$ref": "#/$defs/LanguageEnum"
    },
    "from_number": {
      "anyOf": [
        {
          "type": "string",
          "title": "From Number"
        },
        {
          "type": "null"
        }
      ],
      "title": "From Number",
      "description": "Phone number for native interactions. External-channel interactions return `null`."
    },
    "to_number": {
      "anyOf": [
        {
          "type": "string",
          "title": "To Number"
        },
        {
          "type": "null"
        }
      ],
      "title": "To Number",
      "description": "Phone number for native interactions. External-channel interactions return `null`."
    },
    "status": {
      "type": "string",
      "title": "Status"
    },
    "transferred": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "title": "Transferred",
      "description": "Indicates if the interaction was transferred. External-channel interactions return `null`."
    },
    "handoff_metadata": {
      "anyOf": [
        {
          "$ref": "#/$defs/HandoffMetadata"
        },
        {
          "type": "null"
        }
      ],
      "title": "Handoff Metadata",
      "description": "Metadata about the handoff when the interaction was transferred to an external provider (e.g. Five9). External-channel interactions return `null`."
    },
    "direction": {
      "anyOf": [
        {
          "type": "string",
          "title": "Direction"
        },
        {
          "type": "null"
        }
      ],
      "title": "Direction",
      "description": "The direction of the interaction (inbound/outbound). External-channel interactions return `null`."
    },
    "tags": {
      "type": "array",
      "title": "Tags",
      "description": "Tags associated with the interaction",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "color": {
            "type": "string"
          }
        }
      }
    },
    "started_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Started At"
    },
    "ended_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Ended At"
    },
    "duration": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Duration"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "title": "Created At",
      "description": "For native interactions this is the record creation time. For external-channel interactions this is the underlying session's ingestion time. Note: `created_at` sorting and the `created_at_gte`/`created_at_lte` filters order external-channel interactions by their call (leg start) time, not by this ingestion timestamp, so a returned `created_at` value may fall outside the requested filter window."
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "title": "Updated At",
      "description": "Time the interaction record was last updated. For external-channel interactions this is the underlying session's last update time."
    },
    "external_identifiers": {
      "anyOf": [
        {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        {
          "type": "null"
        }
      ],
      "title": "External Identifiers",
      "description": "External identifiers associated with the interaction"
    },
    "params": {
      "anyOf": [
        {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        {
          "type": "null"
        }
      ],
      "title": "Params",
      "description": "Parameters associated with the interaction"
    },
    "transcripts": {
      "items": {
        "anyOf": [
          {
            "$ref": "#/$defs/CallTranscriptResponse"
          },
          {
            "$ref": "#/$defs/ExternalChannelTranscriptResponse"
          }
        ]
      },
      "type": "array",
      "title": "Transcripts",
      "description": "Transcript item shape depends on the interaction `type`."
    },
    "recording_presigned_url": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Recording Presigned Url",
      "description": "Presigned URL for the recording (for voice modality only). External-channel interactions return `null`."
    },
    "answered_by": {
      "anyOf": [
        {
          "$ref": "#/$defs/AnsweredByEnum"
        },
        {
          "type": "null"
        }
      ],
      "title": "Answered By",
      "description": "Answered-by classification for native voice interactions. External-channel interactions return `null`."
    },
    "analyzers": {
      "type": "array",
      "title": "Analyzers",
      "description": "List of analyzers configured for this interaction",
      "items": {
        "$ref": "#/$defs/AnalyzerResponse"
      }
    },
    "analysis_results": {
      "type": "array",
      "title": "Analysis Results",
      "description": "Results from analyzers that have completed",
      "items": {
        "$ref": "#/$defs/AnalysisResultResponse"
      }
    },
    "summary": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Summary",
      "description": "The summary of the interaction if available"
    },
    "recording_presigned_urls": {
      "type": "array",
      "items": {
        "type": "string",
        "format": "uri"
      },
      "description": "Presigned URLs for all playable recordings in chronological order. External calls can have multiple recordings per session. URLs expire after one hour. Deleted, excluded, and recordings awaiting required audio redaction are omitted; an empty array means no recordings are currently playable. If URL signing fails for a recording, its URL is omitted and the call data is still returned."
    }
  },
  "type": "object",
  "required": [
    "id",
    "type",
    "status",
    "started_at",
    "created_at",
    "updated_at",
    "transcripts",
    "recording_presigned_urls"
  ],
  "$defs": {
    "AnalysisResultResponse": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "title": "Id",
          "description": "Unique identifier for the analysis result"
        },
        "analyzer_id": {
          "type": "string",
          "format": "uuid",
          "title": "Analyzer Id",
          "description": "Identifier of the analyzer that produced this result"
        },
        "prompt": {
          "type": "string",
          "title": "Prompt",
          "description": "The prompt used for analysis"
        },
        "output_config": {
          "type": "object",
          "title": "Output Config",
          "description": "Configuration for the expected output format"
        },
        "result": {
          "type": "object",
          "title": "Result",
          "description": "The analysis result, structure depends on the output_config"
        }
      },
      "required": [
        "id",
        "analyzer_id",
        "prompt",
        "output_config",
        "result"
      ],
      "title": "AnalysisResultResponse"
    },
    "AnalyzerResponse": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "title": "Id",
          "description": "Unique identifier for the analyzer"
        },
        "prompt": {
          "type": "string",
          "title": "Prompt",
          "description": "The prompt used for analysis"
        },
        "output_config": {
          "type": "object",
          "title": "Output Config",
          "description": "Configuration for the expected output format",
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "string",
                "boolean",
                "datetime",
                "object"
              ],
              "description": "The type of output expected"
            },
            "properties": {
              "type": "object",
              "description": "Required when type is 'object'. Defines the structure of the object",
              "additionalProperties": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "string",
                      "boolean",
                      "datetime"
                    ]
                  }
                }
              }
            }
          }
        }
      },
      "required": [
        "id",
        "prompt",
        "output_config"
      ],
      "title": "AnalyzerResponse"
    },
    "AnsweredByEnum": {
      "type": "string",
      "enum": [
        "voicemail",
        "human",
        "no_answer",
        "unknown"
      ],
      "title": "Answered By",
      "description": "Indicates how the call was answered - by a human, voicemail, or if there was no answer"
    },
    "CallTranscriptResponse": {
      "properties": {
        "text": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Text"
        },
        "role": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Role"
        },
        "timestamp": {
          "type": "number",
          "title": "Timestamp",
          "description": "When the entry was recorded, as a Unix timestamp in seconds"
        },
        "function_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Function Name"
        },
        "arguments": {
          "anyOf": [
            {
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Arguments"
        }
      },
      "type": "object",
      "required": [
        "text",
        "role",
        "timestamp",
        "function_name",
        "arguments"
      ],
      "title": "CallTranscriptResponse"
    },
    "ExternalChannelTranscriptResponse": {
      "properties": {
        "speaker": {
          "type": "string",
          "title": "Speaker"
        },
        "text": {
          "type": "string",
          "title": "Text"
        },
        "start": {
          "type": "number",
          "title": "Start"
        },
        "end": {
          "type": "number",
          "title": "End"
        },
        "confidence": {
          "type": "number",
          "title": "Confidence"
        },
        "channel": {
          "type": "string",
          "title": "Channel"
        }
      },
      "type": "object",
      "required": [
        "speaker",
        "text",
        "start",
        "end",
        "confidence"
      ],
      "title": "ExternalChannelTranscriptResponse"
    },
    "Five9HandoffMetadata": {
      "type": "object",
      "title": "Five9HandoffMetadata",
      "description": "Details of a transfer to Five9.",
      "properties": {
        "conversation_id": {
          "type": "string",
          "title": "Conversation ID",
          "description": "The Five9 conversation ID. Use this to correlate with Five9's API."
        },
        "tenant_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Tenant Name",
          "description": "The Five9 tenant name used for the transfer."
        },
        "campaign_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Campaign Name",
          "description": "The Five9 campaign the conversation was routed to."
        },
        "transferred_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Transferred At",
          "description": "When the transfer occurred (ISO 8601)."
        }
      }
    },
    "HandoffMetadata": {
      "type": "object",
      "title": "HandoffMetadata",
      "description": "Metadata about a transfer to an external provider.",
      "properties": {
        "five9": {
          "anyOf": [
            {
              "$ref": "#/$defs/Five9HandoffMetadata"
            },
            {
              "type": "null"
            }
          ],
          "title": "Five9",
          "description": "Five9 handoff details. Present when the transfer was to Five9."
        }
      }
    },
    "LanguageEnum": {
      "type": "string",
      "enum": [
        "en",
        "es",
        "ar"
      ],
      "title": "Language",
      "description": "The language to use for the call - English (en) or Spanish (es)"
    },
    "ModalityEnum": {
      "type": "string",
      "enum": [
        "voice",
        "text"
      ],
      "title": "Modality",
      "description": "The modality of the interaction - voice calls or text conversations"
    }
  }
}