> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/tposs/6.14/llms.txt) (all documentation: [llms.txt](https://docs.cennso.com/llms.txt)). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cennso.com/components/tposs/6.14/api-reference/cdr_api.md).

# CDR API

The CDR API allows to read CDRs in two different ways: Read a single CDR or
retrieve a list of CDRs.

The CDR API exposes the following data model to the consumer:

## Data model

```
   object CDR {
      CdrId : string
      SessionId : string
      SubscriberId : string
      ChargingAccountId : string
      TariffId : string
      UserId : string
      Username : string
      ServiceId : string
      UsedVolumeIn : uint64
      UsedVolumeOut : uint64
      StartTime : string
      SessionTime : uint32
      EndTime : string
      TerminationCause : string
      Ip : inet:ip-address
      NatIp : inet:ip-address
      NatPortRangeStart : inet:port-number (uint16)
      NatPortRangeEnd : inet:port-number (uint16)
      BalanceId : string
      IMSI : string
      IMEI : string
      IMEISV : string
      Homecountry : string
      CarrierGroupId : string
      MccMnc : string
      InitialBalanceId : string
      ExcessVolumeIn : uint64
      ExcessVolumeOut : uint64
      ExcessVolumeTotal : uint64
   }
```

| Attribute | Description
|---|---
| CdrId | UUID (version 4)
| SessionId | The `SessionId` identifies the PCS session object. The session object includes all relevant attributes that used in the CDR.
| SubscriberId | A subscriber is used to group a set of users. It represents the relationship with a customer. As an analogy, you can think of subscribers as representing the contract with the customer.
| ChargingAccountId | Given by the 3rd party system AAX.
| TariffId | Unique identifier for the tariff which is associated with the `ChargingAccountId`.
| UserId | A user is identified by his private user identity and represents a device that a customer uses to access services. The canonical analogy for a user is the SIM card (`IMSI`).
| Username | Name of the User.
| ServiceId | Identifier for the used service.
| UsedVolumeIn | Incoming traffic in bytes
| UsedVolumeOut | Outgoing traffic in bytes
| StartTime | UTC time when the CDR was started.
| SessionTime | Duration of the service usage in seconds.
| EndTime | UTC time when the CDR was closed.
| TerminationCause | Reason for the CDR generation.
| Ip | IP address of the device associated with the session.
| NatIp | NAT IP address of the device associated with the session when using port-based NAT.
| NatPortRangeStart | Start of port range when using port-based NAT.
| NatPortRangeEnd | End of port range when using port-based NAT.
| BalanceId | Unique identifier for the balance object.
| Homecountry | ISO 3166-1 Alpha-2 code of user home country.
| InitialBalanceId | ID of parent balance (if it exists)
| ExcessVolumeIn | Number of incoming bytes exceeding the permitted amount of bytes.
| ExcessVolumeOut | Number of outgoing bytes exceeding the permitted amount of bytes.
| ExcessVolumeTotal | Total number of bytes exceeding the permitted amount of bytes.
| IMSI | Unique identifier of a SIM card.
| IMEI | Unique identifier of a user device (15 digits).
| IMEISV | Unique identifier of a user device with Software Version Number (16 digits).
| CarrierGroupId | Represents the carriers that are combined in groups. `CarrierGroup` s will be used to define the allowed Carriers for usage of `Balance` s.
| MccMnc | MCCMNC combination as defined in RADIUS Requests.

## Methods

### Cdr.Read

Returns the charging data record associated with the given `CdrId`.
Returns an error if no associated CDR can be found.

Following parameters could be passed:

| Name | Type | Requirement | Note |
|---|---|---|---|
| AuthKey | AuthKey | required | Pre-shared authentication key. |
| FeId | String | required | Static frontend identifier which should be unique |
| | | | to the system. |
| FeSId | String | required | Dynamic frontend session identifier which should be reset upon system startup.
| CdrId | String | required | Unique charging data record identifier (UUID version 4).

Example of request:

```
   $ curl -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d
     '{
         "id": "1", "jsonrpc": "2.0",
         "method": "Cdr.Read",
         "params": {
            "AuthKey": "secret",
            "FeId": "TPUIBrowser",
            "FeSId": "TPUIBrowser",
            "CdrId": "07d18201-8344-4a7f-b112-92dd745812ec",
         }
      }' http://127.0.0.1:12001
```

Example of response:

```
   {
      "id": "101", "jsonrpc": "2.0",
      "result": {
          "CdrId": "07d18201-8344-4a7f-b112-92dd745812ec"
          "SessionId": "tpnet-6uR0lPmIpufi3MLt@session.<tenant>",
          "SubscriberId": "700030010@subscriber.<tenant>",
          "ChargingAccountId": "700032310@account.charging.<tenant>",
          "TariffId": "online@tariff.<tenant>",
          "UserId": "701976710@user.<tenant>",
          "Username": "262019876543210",
          "ServiceId": "Online@service.<tenant>",
          "UsedVolumeIn": 4746862,
          "UsedVolumeOut": 46862,
          "StartTime": "2015-05-07 20:43:22Z",
          "SessionTime": 3600,
          "EndTime": "2015-05-07 21:43:22Z",
          "TerminationCause": "Session-Timeout",
          "Ip": "62.12.2.22",
          "NatIp": "172.16.1.12",
          "NatPortRangeStart": 12210,
          "NatPortRangeEnd": 12250,
          "BalanceId": "13@balance.charging.<tenant>"
          “IMSI”: “262019876543210“,
          “IMEI”: “354311050022709“,
          “IMEISV”: “3543110500227002“,
          "Homecountry": "DE",
          "CarrierGroupId": "27@carriergroup.charging.<tenant>",
          "MccMnc": "23203",
          "InitialBalanceId": "3",
          "ExcessVolumeIn": 0,
          "ExcessVolumeOut": 0,
          "ExcessVolumeTotal": 15
      }
   }
```

### Cdr.Delete

Deletes all account information associated with a charging account object.
Returns an error if no account can be found.

Following parameters could be passed:

| Name | Type | Requirement | Note |
|---|---|---|---|
| AuthKey | AuthKey | required | Pre-shared authentication key. |
| FeId | String | required | Static frontend identifier which should be unique |
| | | | to the system. |
| FeSId | String | required | Dynamic frontend session identifier which should be reset upon system startup.
| CdrId | String | required | Unique charging data record identifier (UUID version 4).

Example of request:

```
   $ curl -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d
     '{
         "id": "1", "jsonrpc": "2.0",
         "method": "Cdr.Delete",
         "params": {
            "AuthKey": "secret",
            "FeId": "TPUIBrowser",
            "FeSId": "TPUIBrowser",
            "CdrId": "07d18201-8344-4a7f-b112-92dd745812ec"
         }
      }' http://127.0.0.1:12001
```

Example of response:

```
   {
      "id": "101", "jsonrpc": "2.0",
      "result": "true"
   }
```

### Cdr.BulkRead

Returns a list of CDRs associated with the given ids. In addition a list of ids
which could not be associated with a CDR is returned.

Following parameters could be passed:

| Name | Type | Requirement | Note |
|---|---|---|---|
| AuthKey | AuthKey | required | Pre-shared authentication key. |
| FeId | String | required | Static frontend identifier which should be unique |
| | | | to the system. |
| FeSId | String | required | Dynamic frontend session identifier which should be reset upon system startup.
| CdrIds | List | required | Contains the CDR Ids (strings) to be requested |

Example of request:

```
   $ curl -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d
     '{
         "id": "1", "jsonrpc": "2.0",
         "method": "Cdr.BulkRead",
         "params": {
            "AuthKey": "secret",
            "FeId": "bss1.<tenant>",
            "FeSId": "13.bss1.<tenant>",
            "CdrIds": [
               "07d18201-8344-4a7f-b112-92dd745812ec",
               "32118201-1234-4a7f-b112-92dd745812ec"
            ]
         }
      }' http://127.0.0.1:12001
```

Example of response:

```
   {
      "id": "101", "jsonrpc": "2.0",
      "result": {
         "TotalRcords": 1,
         "TotalErrors": 1,
         "Records": [
            {
               "CdrId": "07d18201-8344-4a7f-b112-92dd745812ec"
               "SessionId": "tpnet-6uR0lPmIpufi3MLt@session.<tenant>",
               "SubscriberId": "700030010@subscriber.<tenant>",
               "ChargingAccountId": "700032310@account.charging.<tenant>",
               "TariffId": "online@tariff.<tenant>",
               "UserId": "701976710@user.<tenant>",
               "Username": "262019876543210",
               "ServiceId": "Online@service.<tenant>",
               "UsedVolumeIn": 4746862,
               "UsedVolumeOut": 46862,
               "StartTime": "2015-05-07 20:43:22Z",
               "SessionTime": 3600,
               "EndTime": "2015-05-07 21:43:22Z",
               "TerminationCause": "Session-Timeout",
               "Ip": "62.12.2.22",
               "NatIp": "172.16.1.12",
               "NatPortRangeStart": 12210,
               "NatPortRangeEnd": 12250,
               "BalanceId": "13@balance.charging.<tenant>"
               “IMSI”: “262019876543210“,
               “IMEI”: “354311050022709“,
               “IMEISV”: “3543110500227002“,
               "Homecountry": "DE",
               "CarrierGroupId": "27@carriergroup.charging.<tenant>",
               "MccMnc": "23203",
               "InitialBalanceId": "3",
               "ExcessVolumeIn": 0,
               "ExcessVolumeOut": 0,
               "ExcessVolumeTotal": 15
            }
         ],
         "Errors": [
            "32118201-1234-4a7f-b112-92dd745812ec"
         ]
      }
   }
```

### Cdr.List

If the number of results exceeds the internal query limit, only an initial
subset will be returned. Returns an error if no valid query parameter is passed.

Following parameters could be passed:

| Name | Type | Requirement | Note |
|---|---|---|---|
| AuthKey | AuthKey | required | Pre-shared authentication key. |
| FeId | String | required | Static frontend identifier which should be unique |
| | | | to the system. |
| FeSId | String | required | Dynamic frontend session identifier which should be reset upon system startup.
| Limit | uint16 | optional | Limits the size of the result set. |
| Offset | uint16 | optional | Number of results to be skipped in the result set. |
| Sort | string | optional | See :ref:`sorting`. |
| Filter | string | optional | See :ref:`filtering`. |
| Fields | string | optional | List of attributes to be returned for each result. |

Example of request:

```
   $ curl -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d
     '{
         "id": "1", "jsonrpc": "2.0",
         "method": "Cdr.List",
         "params": {
            "AuthKey": "secret",
            "FeId": "bss1.<tenant>",
            "FeSId": "13.bss1.<tenant>",
            "Filter": "SubscriberId:is:700030010@subscriber.int.str.carisp.net"
         }
      }' http://127.0.0.1:12001
```

Example of response:

```
   {
      "id": "101", "jsonrpc": "2.0",
      "result": {
         "TotalRcords": 1,
         "Records": [
            {
               "CdrId": "07d18201-8344-4a7f-b112-92dd745812ec"
               "SessionId": "tpnet-6uR0lPmIpufi3MLt@session.<tenant>",
               "SubscriberId": "700030010@subscriber.<tenant>",
               "ChargingAccountId": "700032310@account.charging.<tenant>",
               "TariffId": "online@tariff.<tenant>",
               "UserId": "701976710@user.<tenant>",
               "Username": "262019876543210",
               "ServiceId": "Online@service.<tenant>",
               "UsedVolumeIn": 4746862,
               "UsedVolumeOut": 46862,
               "StartTime": "2015-05-07 20:43:22Z",
               "SessionTime": 3600,
               "EndTime": "2015-05-07 21:43:22Z",
               "TerminationCause": "Session-Timeout",
               "Ip": "62.12.2.22",
               "NatIp": "172.16.1.12",
               "NatPortRangeStart": 12210,
               "NatPortRangeEnd": 12250,
               "BalanceId": "13@balance.charging.<tenant>"
               “IMSI”: “262019876543210“,
               “IMEI”: “354311050022709“,
               “IMEISV”: “3543110500227002“,
               "Homecountry": "DE",
               "CarrierGroupId": "27@carriergroup.charging.<tenant>",
               "MccMnc": "23203",
               "InitialBalanceId": "3",
               "ExcessVolumeIn": 0,
               "ExcessVolumeOut": 0,
               "ExcessVolumeTotal": 15
            }
         ]
      }
   }
```
