> ## Documentation Index
> Fetch the complete documentation index at: https://docs.get2dial.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sync CDRs to your warehouse

> Pull call detail records into your own database on a schedule, without re-fetching calls you've already synced.

Pull call detail records into your own database on a schedule, without re-fetching calls
you've already synced.

**Time required:** \~15 minutes
**You will need:** an API key with read access to CDRs — see [Authentication](/developers/authentication)

## Steps

<Steps>
  <Step title="Fetch a page of CDRs">
    ```bash theme={null}
    curl "https://api.get2dial.com/api/v1/cdrs?from=2026-08-01T00:00:00Z&limit=100" \
      -H "Authorization: Bearer <your-api-key>"
    ```

    Each record includes `call_id`, `direction`, `caller`, `callee`, `start_time`,
    `duration_seconds`, `status`, `hangup_cause`, and more — see [Call and lead
    states](/reference/call-and-lead-states) for what `status` does and doesn't tell you.
  </Step>

  <Step title="Page through the rest">
    Use `offset` to page — increment it by your `limit` and keep requesting until a response
    returns fewer records than you asked for.
  </Step>

  <Step title="Store each record, keyed by call_id">
    Upsert on `call_id` in your own database — this makes a re-run safe if a sync is
    interrupted partway through.
  </Step>

  <Step title="Advance your sync window for next time">
    Record the latest `start_time` you saw. On your next run, set `from` to that value (or
    slightly earlier, to tolerate clock skew) instead of `2026-08-01T00:00:00Z`.
  </Step>
</Steps>

## What you accomplished

A repeatable, incremental sync you can run on a schedule — each run only asks for calls since
the last one, and upserting by `call_id` makes re-running a window harmless.

## Next steps

<CardGroup cols={2}>
  <Card title="Push leads into a campaign" href="/developers/recipes/push-leads-into-a-campaign" />

  <Card title="React to call events" href="/developers/recipes/react-to-call-events" />
</CardGroup>
