{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/didlogic-com/json-schema/didlogic-com-cdr-list-response-schema.json",
  "title": "CdrListResponse",
  "description": "Paginated list of CDR records",
  "x-generated": "2026-11-05",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/didlogic-com-openapi.yml#/components/schemas/CdrListResponse",
  "type": "object",
  "required": [
    "calls",
    "pagination"
  ],
  "properties": {
    "calls": {
      "type": "array",
      "description": "Array of call detail records",
      "items": {
        "oneOf": [
          {
            "$ref": "#/$defs/SipCdr"
          },
          {
            "$ref": "#/$defs/IncomingCdr"
          },
          {
            "$ref": "#/$defs/WebCdr"
          }
        ]
      }
    },
    "pagination": {
      "$ref": "#/$defs/Pagination"
    }
  },
  "$defs": {
    "BaseCdr": {
      "type": "object",
      "description": "Base call detail record with common fields",
      "required": [
        "timestamp",
        "type",
        "amount",
        "duration",
        "from",
        "to",
        "amd_status",
        "amd_score",
        "hangup_cause"
      ],
      "properties": {
        "timestamp": {
          "type": "string",
          "format": "date-time",
          "description": "Call start time in ISO 8601 format (UTC)"
        },
        "type": {
          "type": "string",
          "description": "Call type",
          "enum": [
            "sip",
            "incoming",
            "web",
            "api"
          ]
        },
        "amount": {
          "type": "number",
          "format": "float",
          "description": "Call cost (charged/credited amount)"
        },
        "duration": {
          "type": "integer",
          "description": "Call duration in seconds. 0 = missed call",
          "minimum": 0
        },
        "from": {
          "type": "string",
          "description": "Caller number/identifier"
        },
        "to": {
          "type": "string",
          "description": "Destination number/identifier"
        },
        "amd_status": {
          "type": [
            "string",
            "null"
          ],
          "description": "Answering machine detection (AMD) verdict of an outbound call:\n- `machine` — AMD detected an answering machine\n- `human` — AMD detected a person\n- `notsure` — AMD ran but could not tell a machine from a person, for example on silence, unclear audio or a timeout\n\n`null` when no AMD result was recorded for the call, which is always the case for incoming calls.\n"
        },
        "amd_score": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Probability that an answering machine picked up, as a percentage from 0 to 100, as reported by the AMD detector.\nIt is not a confidence in `amd_status`, and it carries no meaning when `amd_status` is `notsure`.\n`null` whenever `amd_status` is `null`.\n"
        },
        "hangup_cause": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "AMD_MACHINE",
            "NORMAL_CLEARING",
            "NO_ANSWER",
            "BUSY",
            "FAILED",
            null
          ],
          "description": "How the call ended:\n- `AMD_MACHINE` — AMD detected an answering machine; takes precedence over the other values\n- `NORMAL_CLEARING` — the call was answered\n- `NO_ANSWER` — nobody answered, including calls the caller cancelled before an answer\n- `BUSY` — the called party was busy\n- `FAILED` — the call could not be connected\n\n`null` for calls made before hangup causes were recorded, for calls whose outcome the platform did not recognise,\nand for API calls that never reached the destination number.\n"
        }
      }
    },
    "IncomingCdr": {
      "allOf": [
        {
          "$ref": "#/$defs/BaseCdr"
        },
        {
          "type": "object",
          "description": "Incoming call detail record",
          "properties": {
            "did_number": {
              "type": [
                "string",
                "null"
              ],
              "description": "DID number that received the call (purchased virtual number)"
            }
          }
        }
      ]
    },
    "Pagination": {
      "type": "object",
      "description": "Pagination metadata for list responses",
      "required": [
        "page",
        "per_page",
        "total_pages",
        "total_records"
      ],
      "properties": {
        "page": {
          "type": "integer",
          "description": "Current page number (1-based)",
          "minimum": 1
        },
        "per_page": {
          "type": "integer",
          "description": "Number of records per page",
          "minimum": 1
        },
        "total_pages": {
          "type": "integer",
          "description": "Total number of pages available",
          "minimum": 0
        },
        "total_records": {
          "type": "integer",
          "description": "Total number of records",
          "minimum": 0
        }
      }
    },
    "SipCdr": {
      "allOf": [
        {
          "$ref": "#/$defs/BaseCdr"
        },
        {
          "type": "object",
          "description": "Outbound SIP call detail record",
          "properties": {
            "destination_name": {
              "type": "string",
              "description": "Destination country/region name"
            },
            "sip_account": {
              "type": [
                "string",
                "null"
              ],
              "description": "SIP account used for the call"
            },
            "per_minute": {
              "type": [
                "number",
                "null"
              ],
              "format": "float",
              "description": "Per-minute rate. null = unknown, 0 = free"
            }
          }
        }
      ]
    },
    "WebCdr": {
      "allOf": [
        {
          "$ref": "#/$defs/BaseCdr"
        },
        {
          "type": "object",
          "description": "Web call detail record (no additional fields)"
        }
      ]
    }
  }
}