After sending messages or creating calls, you can check those by using the cdrRecords query which returns a paginatedCdrResult object type. This query is a bit more complex due to the usage of advanced GraphQL features like fragments and cursor based pagination.
Arguments which can be sent are listed below. The exclamation mark (!)means a parameter is mandatory, otherwise it's optional:
companyId: ID
For which company to list CDRs (only for admin users)
type: CdrType!
The type of the CDR records to list
startDatetime: DateTime!
Will return all records with datetime >= startDatetime
endDatetime: DateTime!
Will return all records with datetime < endDatetime (UTC based), max value is now
cursor: String
Used to paginate, returns results for the passed cursor (if any)
limit: Int
Limit the number of results per page, default is 100, max is 1000
Sample Query
query cdrRecordsQuery(
$type: CdrType!
$startDatetime: DateTime!
$endDatetime: DateTime!
$limit: Int
$cursor: String
) {
cdrRecords(
type: $type
startDatetime: $startDatetime
endDatetime: $endDatetime
limit: $limit
cursor: $cursor
) {
exportLink
paginationInfo {
nextCursor
limit
}
cdrs {
... on ApiCdr {
datetime
from
destination
status
charge
type
}
... on MessageCdr {
datetime
fromNumber
toNumber
direction
status
charge
type
}
... on VoiceCdr {
datetime
callId
sourceAni
destinationNumber
didUsed
sessionTime
status
calledRate
charge
callType
aniIi
}
}
}
}
In this query GraphQL fragments are used (e.g. ... on MessageCdr { ... }, they are needed because what we return is a union of types for cdrs, and the fields are depending on the passed type. In our example below we're using SMS, but the fragments can be specified for each field in a general query, only change the type.
In our case the type is SMS, you send it as an uppercase string, example of variables sent:
We're using pagination for this endpoint because there can be milions of records for short time frames. To paginate through the results tweak the previous query so it looks like this (notice the new $limit and $cursor arguments):
We can paginate until the result we get has nextCursor: null, when it's null it means we reached the end.
Exporting CDRs
You can export CDRs by using the exportLink which the cdrRecords query provides. The easiest way is to click on the link, but you can also do a server-side or client-side download if you want to save the results.
The links in the above example won't work since they're fake but you can generate one with your queries. The export will trigger a CSV file download (via HTTP streams) and include the fields you specified in the query, but the pagination options will be ignored.
The export link is protected by a signature and cannot be tampered with, once generated it's public.
The export process has a timeout of 20 minutes, so if you notice the export timing out reduce the startDatetime and endDatetime period to something manageable and try again