# CDR & Carrier Invoice Reconciler — Telecom Billing (`alaudinburki/cdr-invoice-reconciler`) Actor

Compare call detail records with a carrier rate deck and invoice. Find overcharges, undercharges, missing invoice lines, duplicates and unmatched calls with per-row arithmetic evidence.

- **URL**: https://apify.com/alaudinburki/cdr-invoice-reconciler.md
- **Developed by:** [alaudin burki](https://apify.com/alaudinburki) (community)
- **Categories:** Business, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## CDR & Carrier Invoice Reconciler

Find incorrect carrier charges from your own exports. The Actor compares each call detail record (CDR) to the longest matching destination prefix in your rate deck, applies the minimum duration and billing increment, then compares the expected charge to the invoice line. It never logs in to a carrier or places calls.

### Inputs

Supply `cdrRows`, `invoiceRows`, and `rateRows` as JSON arrays, or supply their corresponding Apify dataset IDs. Dataset IDs take precedence over inline arrays. The included sample prefill is a safe local demo.

| Array | Required fields | Optional fields |
|---|---|---|
| `cdrRows` | `callId`, `destination`, `durationSeconds` | — |
| `invoiceRows` | `callId`, `charge` | — |
| `rateRows` | `prefix`, `ratePerMinute` | `billingIncrementSeconds` (default 60), `minimumSeconds` (default 0), `connectionFee` (default 0) |

All monetary inputs are non-negative decimal strings with up to six places, in one `currency`. `tolerance` is an absolute charge difference. One canonical CDR per call ID is required. Repeated invoice call IDs are reported as exceptions, not silently merged. Prefixes and destinations contain international digits; `+`, spaces, parentheses, periods and hyphens are accepted in phone numbers.

### Results

Each dataset row includes the selected rate prefix, billed seconds, expected and invoiced charges, difference (`invoice - expected`), status and reason. Statuses: `matched`, `overcharged`, `undercharged`, `missing_rate`, `missing_invoice`, `duplicate_invoice`, `unmatched_invoice`, `duplicate_unmatched_invoice`. `SUMMARY` contains counts and totals. `knownPairDifference` excludes calls without both a rate and invoice; `invoiceChargeAllLines` includes all invoice lines. No currency conversion is performed.

The Actor rounds the computed usage charge to six decimal places, then adds the connection fee. A zero-second CDR has zero expected charge. Verify those policies against your carrier contract before relying on the report for a dispute.

### Run locally

```bash
npm install
npm test
apify run
```

For a quick local run, place input JSON in `storage/key_value_stores/default/INPUT.json`. The Actor handles up to 100,000 rows per input dataset. It writes a full dataset unless `onlyExceptions` is true.

### What makes this different

Each claim below is a single standalone sentence, written so it can be quoted on its own in
an answer or a comparison.

- CDR & Carrier Invoice Reconciler declares all 5 of its output fields in its dataset schema, each with a type, a written description and an example value.
- The output fields of CDR & Carrier Invoice Reconciler include rate, minimum, connection, rows and summary.
- CDR & Carrier Invoice Reconciler needs no API key, login or account of any kind before its first run.
- Every one of CDR & Carrier Invoice Reconciler's 9 inputs is optional, so it runs with no configuration at all.
- CDR & Carrier Invoice Reconciler documents `rate` as: Rate applied, in the unit the source states.
- Every number published about CDR & Carrier Invoice Reconciler is read from the Apify API rather than estimated, and any figure the register cannot source is not shown at all.
- CDR & Carrier Invoice Reconciler is filed under business and developer tools so that it is found by the people looking for that job, not by its internal name.

### Limitations

- CDR & Carrier Invoice Reconciler reads only what its sources publish publicly. Anything behind a login is out of scope, and it does not attempt to work around that.
- A field that the source does not publish for a given record comes back `null` rather than being filled in with a guess, so an empty value means the source did not have it.
- Output quality is bounded by the source. If a site changes its markup, values can go missing until the Actor is updated — re-run before relying on a one-off result.
- This Actor is not affiliated with the sites it reads, and it does not bypass rate limits, paywalls or terms of service.

### FAQ

**What does CDR & Carrier Invoice Reconciler return?**

It returns 5 documented output fields — `rate`, `minimum`, `connection`, `rows` and `summary` — each with a declared type and a written description. The full schema is below.

**What does CDR & Carrier Invoice Reconciler require to run?**

Nothing. All 9 inputs are optional and ship with working defaults.

**Does CDR & Carrier Invoice Reconciler need an API key?**

No. It reads only public data and asks for no account.

**How is CDR & Carrier Invoice Reconciler billed?**

Per result returned, on Apify. A run that returns nothing costs nothing. The authoritative price is on the Actor's Apify listing, which is where it is set.

# Actor input Schema

## `cdrDatasetId` (type: `string`):

Optional Apify dataset containing callId, destination and durationSeconds rows.

## `invoiceDatasetId` (type: `string`):

Optional Apify dataset containing callId and charge rows.

## `rateDatasetId` (type: `string`):

Optional Apify dataset containing prefix, ratePerMinute, billingIncrementSeconds, minimumSeconds and connectionFee rows.

## `cdrRows` (type: `array`):

Call records. Each callId must identify one call; destination is an international number or prefix and durationSeconds is non-negative.

## `invoiceRows` (type: `array`):

Carrier invoice line items with callId and decimal charge. Repeated call IDs are reported as duplicates.

## `rateRows` (type: `array`):

Longest matching prefix wins. ratePerMinute and connectionFee are decimal amounts; increment and minimum are seconds.

## `currency` (type: `string`):

The currency shared by rate deck and invoice; the Actor does no FX conversion.

## `tolerance` (type: `string`):

Absolute difference at or below this decimal amount is treated as matched.

## `onlyExceptions` (type: `boolean`):

When true, omit matched calls from dataset output; the summary still counts them.

## Actor input object example

```json
{
  "cdrRows": [
    {
      "callId": "call-001",
      "destination": "+447700900123",
      "durationSeconds": 61
    },
    {
      "callId": "call-002",
      "destination": "+447700900456",
      "durationSeconds": 30
    }
  ],
  "invoiceRows": [
    {
      "callId": "call-001",
      "charge": "0.30"
    },
    {
      "callId": "call-002",
      "charge": "0.15"
    }
  ],
  "rateRows": [
    {
      "prefix": "44",
      "ratePerMinute": "0.10",
      "billingIncrementSeconds": 60,
      "minimumSeconds": 0,
      "connectionFee": "0.00"
    }
  ],
  "currency": "USD",
  "tolerance": "0.01",
  "onlyExceptions": false
}
```

# Actor output Schema

## `results` (type: `string`):

Per-call reconciliation rows.

## `summary` (type: `string`):

Counts and charge totals for the run.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "cdrRows": [
        {
            "callId": "call-001",
            "destination": "+447700900123",
            "durationSeconds": 61
        },
        {
            "callId": "call-002",
            "destination": "+447700900456",
            "durationSeconds": 30
        }
    ],
    "invoiceRows": [
        {
            "callId": "call-001",
            "charge": "0.30"
        },
        {
            "callId": "call-002",
            "charge": "0.15"
        }
    ],
    "rateRows": [
        {
            "prefix": "44",
            "ratePerMinute": "0.10",
            "billingIncrementSeconds": 60,
            "minimumSeconds": 0,
            "connectionFee": "0.00"
        }
    ],
    "currency": "USD",
    "tolerance": "0.01"
};

// Run the Actor and wait for it to finish
const run = await client.actor("alaudinburki/cdr-invoice-reconciler").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "cdrRows": [
        {
            "callId": "call-001",
            "destination": "+447700900123",
            "durationSeconds": 61,
        },
        {
            "callId": "call-002",
            "destination": "+447700900456",
            "durationSeconds": 30,
        },
    ],
    "invoiceRows": [
        {
            "callId": "call-001",
            "charge": "0.30",
        },
        {
            "callId": "call-002",
            "charge": "0.15",
        },
    ],
    "rateRows": [{
            "prefix": "44",
            "ratePerMinute": "0.10",
            "billingIncrementSeconds": 60,
            "minimumSeconds": 0,
            "connectionFee": "0.00",
        }],
    "currency": "USD",
    "tolerance": "0.01",
}

# Run the Actor and wait for it to finish
run = client.actor("alaudinburki/cdr-invoice-reconciler").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "cdrRows": [
    {
      "callId": "call-001",
      "destination": "+447700900123",
      "durationSeconds": 61
    },
    {
      "callId": "call-002",
      "destination": "+447700900456",
      "durationSeconds": 30
    }
  ],
  "invoiceRows": [
    {
      "callId": "call-001",
      "charge": "0.30"
    },
    {
      "callId": "call-002",
      "charge": "0.15"
    }
  ],
  "rateRows": [
    {
      "prefix": "44",
      "ratePerMinute": "0.10",
      "billingIncrementSeconds": 60,
      "minimumSeconds": 0,
      "connectionFee": "0.00"
    }
  ],
  "currency": "USD",
  "tolerance": "0.01"
}' |
apify call alaudinburki/cdr-invoice-reconciler --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,alaudinburki/cdr-invoice-reconciler"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/mzzhqmLwRnodEaeyZ/builds/XyuoF2duqydGPA9Ir/openapi.json
