API Version: Development

Call Reports

Inbound and outbound call reports in various formats. Note that these call reports may take several seconds to run on a busy system, and due to high resource demands from these reports, a lock is held while the report is generated.

Permissions

Requires System-Admin or Billing Call-Summary permissions. A user with Billing / Call Reporting permission may also read this data for companies they have permission to.
IMPORTANT: the billing engine is single-threaded, and will lock while in use. This may result in the following response:
{
	"result": "retry",
	"message": "Another user has billing locked. Please try again in a moment."
}

command 'incalls'

Path: /rest/call/incalls
CDR records from the database are processed into details of inbound calls that have been received. Note that an internal call is both inbound and outbound. This process takes significant CPU and memory resources, so should not be called repeatedly or regularly, and if 2+ users try to use it simultaneously, only the first request will succeed.
{
	"type": "cdr",
	"scope": {
		"company": "company", (optional, default to 'default')
		"day": day-number-to-report (optional),
		"month": month-number-to-report,
		"year": year-number-to-report,
		"days": days to include in day report (optional, default = 1),
		"extensions": [	(optional list of extensions to report on)
			"ext-num",
			...
		]
	}
}
Return value:
{
    "result": "success",
    "values": {
        extension-number: {
            "name": "Extension-name",
            "calls": [
                {
                    "acctid": accounting-id,
                    "calldate": epoch-seconds,
                    "caller": "callers-id",
                    "type": "Internal|External",
                    "ringtime": seconds,
                    "billsecs": seconds,
                    "detail": "Call-disposition",
                    "qtime": "seconds or empty",
                    "qstatus": "Queued-call-disposition or empty"
                },
                ...
                (more-calls)
            ],
        }
        ...
        (more-extensions)
    }
}

Example

{
    "type": "cdr",
    "scope": {
        "company": [
            "test"
        ],
        "month": 2,
        "year": 2017
    }
}
{
    "result": "success",
    "values": {
        "200": {
            "name": "200snom320",
            "calls": [
                {
                    "acctid": 27739,
                    "calldate": 1487850941,
                    "caller": "203",
                    "type": "Internal",
                    "ringtime": 14,
                    "billsecs": 0,
                    "detail": "Not answered",
                    "qtime": "",
                    "qstatus": ""
                }
            ]
        }
    }
}

command 'outcalls'

Path: /rest/call/outcalls
CDR records from the database are processed into details of outbound calls that have been made. Note that an internal call is both inbound and outbound. This process takes significant CPU and memory resources, so should not be called repeatedly or regularly, and if 2+ users try to use it simultaneously, only the first request will succeed.
{
	"type": "cdr",
	"scope": {
		"company": "company", (optional, default to 'default')
		"day": day-number-to-report (optional),
		"month": month-number-to-report,
		"year": year-number-to-report,
		"days": days to include in day report (optional, default = 1),
		"deviceids": [	(optional list of device-ids to report on)
			"device-id is mac + port",
			...
		],
		"keeviomerge": "bool to merge keevio calls with handset calls",
		"recalc": "bool to force recalculate of costs" (VERY high CPU load)
	}
}
Return value:
{
    "result": "success",
    "values": {
        "device-id": {
            "name": "Device-owner",
            "device": "SIP-name",
            "calls": [
                {
                    "acctid": accounting-id,
                    "calldate": epoch-seconds,
                    "type": "Numberr-type",
                    "called_info": "Extra-human-readable-call-info",
                    "called": "called-number-short-form",
                    "dialled": "number-as-dialled",
                    "billsecs": seconds,
                    "ringtime": seconds,
                    "cost": cost-in-configured-units,
                    "trunk": "trunk-id or blank",
                    "cid": "caller-id sent"
                },
                ...
                (more-calls)
            ],
        },
        ...
        (more-devices)
    }
}

Example

{
    "type": "cdr",
    "scope": {
        "company": [
            "test"
        ],
        "month": 2,
        "year": 2017
    }
}
{
    "result": "success",
    "values": {
        "0500000004000": {
            "name": "YealinkRnD T46",
            "device": "rndT46",
            "calls": [
                {
                    "acctid": 26123,
                    "calldate": 1487847464,
                    "type": "Test Number",
                    "called_info": "",
                    "called": "*600",
                    "dialled": "*600",
                    "billsecs": 61,
                    "ringtime": 0,
                    "cost": 0,
                    "trunk": "",
                    "cid": "301"
                }
            ]
        }
    }
}

command 'outsummary'

Path: /rest/call/outsummary
CDR records from the database are processed into a per-company summary. This process takes significant CPU and memory resources, so should not be called repeatedly or regularly, and if 2+ users try to use it simultaneously, only the first request will succeed.
{
	"type": "cdr",
	"scope": {
		"company": "company", (optional, default to show-all)
		"month": month-number-to-report,
		"year": year-number-to-report,
		"keeviomerge": "bool to merge keevio calls with handset calls",
		"detail": "bool to display per-device details",
		"recalc": "bool to force recalculate of costs" (VERY high CPU load)
	}
}
Return value:
{
    "result": "success",
    "values": {
        "company-id": {
            "name": "Company Name",
            "cost": cost,
            "unknown": count calls where cost unknown,
            "handset-id": {
                "name": "handset-owner",
                "device": "device name",
                "cost": cost,
                "seconds": billable-seconds,
                "unknown": count calls where cost unknown
            },
            ...
            (more handsets)
        },
        ...
        (each company)
    }
}

Example

In this example scope.detail is null (so false) so only per-company details are shown.
{
    "type": "cdr",
    "scope": {
        "month": 2,
        "year": 2017
    }
}
{
    "result": "success",
    "values": {
        "default": {
            "name": "Default Company",
            "cost": 1.23,
            "seconds": 217,
            "unknown": 1
        }
    }
}
In this example scope.detail is true.
{
        "type": "cdr",
        "scope": {
                "month": 2,
                "year": 2017,
        "detail": true
        }
}
{
        "result": "success",
        "values": {
                "default": {
                        "name": "Default Company",
                        "cost": 1.23,
            "seconds": 217,
                        "unknown": 1,
                        "0200000000001": {
                                "name": "A User",
                                "device": "softphone",
                                "cost": 1.23,
                "seconds": 217,
                                "unknown": 1
                        }
                }
        }
}

command 'allcalls'

Path: /rest/call/allcalls 6.2.16+
CDR records from the database are processed into details of both inbound and outbound calls that have been made, combining the two reports above. This report also produces data for all companies on the PABX. This process takes significant CPU and memory resources, so should not be called repeatedly or regularly, and if 2+ users try to use it simultaneously, only the first request will succeed.
The simpler query format allows much less filtering as the report is designed to return all data for the specified period.
{
	"type": "cdr",
	"scope": {
		"day": day-number-to-report (optional),
		"month": month-number-to-report,
		"year": year-number-to-report,
		"days": days to include in day report (optional, default = 1),
		"keeviomerge": "bool to merge keevio calls with handset calls",
		"recalc": "bool to force recalculate of costs" (VERY high CPU load)
	}
}
The returned values are a combination of the inbound and outbound call data documented above, cost data is also excluded from this report:
{
    "result": "success",
    "values": {
        "company": {
            "name": "Company name",
            "out": {
                "device-id": {
                    "name": "Device-owner",
                    "device": "SIP-name",
                    "calls": [ ... ]
                },
                ...
                (more devices)
            },
            "in": {
                extension-number: {
                    "name": "Extension-name",
                    "calls": [ ... ]
                },
                ...
                (more extensions)
            }
        },
        ...
        (more companies)
    }
}

Example

{
    "type": "cdr",
    "scope": {
        "year": 2017,
        "month": 5,
        "day": 5,
        "days": 7,
    }
}
{
    "result": "success",
    "values": {
        "acompany": {
            "name": "A Company",
            "in": {
                "446": {
                    "name": "Meeting Room",
                    "calls": [
                         {
                            "acctid": 2012560,
                            "calldate": 1493899151,
                            "caller": "203",
                            "type": "Internal",
                            "ringtime": 2,
                            "billsecs": 0,
                            "detail": "Not answered",
                            "qtime": "",
                            "qstatus": "",
                            "ddi": ""
                        }
                    ]
                }
            },
            "out": {
                "0500000004000": {
                    "name": "YealinkRnD T46",
                    "device": "rndT46",
                    "calls": [
                        {
                            "acctid": 26123,
                            "calldate": 1493895749,
                            "type": "Test Number",
                            "called_info": "",
                            "called": "*600",
                            "dialled": "*600",
                            "billsecs": 61,
                            "ringtime": 0,
                            "cost": 0,
                            "trunk": "",
                            "cid": "301"
                        }
                    ]
                }
            }
        }
    }
}