# Get Call Logs

{% hint style="success" %}
**-** **NEW! -  Interactive API docs, now live!**

Visit [api-docs.plumvoice.com](https://api-docs.plumvoice.com) to **read** Plum API documentation, **build and test requests** in our interactive API sandbox, **review** the responses, and **share** it all with your team.
{% endhint %}

## Get Call Logs

<mark style="color:blue;">`GET`</mark> `https://fuse.plumvoice.com/api/calls/{start}/{end}`

Fetch information about completed outbound calls

#### Path Parameters

| Name  | Type   | Description    |
| ----- | ------ | -------------- |
| start | string | UNIX timestamp |
| end   | string | UNIX timestamp |

#### Query Parameters

| Name   | Type    | Description                                                             |
| ------ | ------- | ----------------------------------------------------------------------- |
| number | string  | The phone number of the deployment for which to retrieve call log data. |
| limit  | integer | The maximum number of records per page to return.                       |
| offset | integer | Indicates the record number that begins the list of returned records.   |

{% tabs %}
{% tab title="200 " %}
{% tabs %}
{% tab title="JSON" %}

```javascript
{
  "calls":[
    {
      "dest":"8009957586",
      "src":"2125551234",
      "start":1529552691,
      "end":1529552697,
      "session_id":"300060;001;1529552581",
      "type":"inbound",
      "log":true
    },
    {
      "dest":"8009957586",
      "src":"6175551234",
      "start":1529550008,
      "end":1529550036,
      "session_id":"400050;001;1529549919",
      "type":"inbound",
      "log":true
    }
  ],
  "total_calls":2
}
```

{% endtab %}

{% tab title="XML" %}

```markup
<?xml version="1.0"?>
<result>
  <calls>
    <item>
      <dest>8669077078</dest>
      <src>3472550011</src>
      <start>1529552691</start>
      <end>1529552697</end>
      <session_id>300060;001;1529552581</session_id>
      <type>inbound</type>
      <log>true</log>
    </item>
    <item>
      <dest>8338605949</dest>
      <src>3472550011</src>
      <start>1529550008</start>
      <end>1529550036</end>
      <session_id>400050;001;1529549919</session_id>
      <type>inbound</type>
      <log>true</log>
    </item>
  </calls>
  <total_calls>2</total_calls>
</result>
```

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

### **Possible Response Codes**

* **200**: success
* **401**: authentication headers invalid or the account is inactive
* **405**: invalid HTTP method supplied (only GET allowed)
* **500**: database error

The return structure contains the following item(s):

| Name         | Data Type | Always Present | Description                                                                                                                                                                      |
| ------------ | --------- | -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| error        | string    | no             | Message indicating what went wrong with the request when the HTTP code is not 200.                                                                                               |
| calls        | mixed     | no             | Array of calls that match the query parameters. Supplied when the HTTP code is 200. See the table below for more information on the data in this item.                           |
| total\_calls | int       | no             | The total number of calls for the given start, end and number parameters. Supplied when the HTTP code is 200. See the table below for more information on the data in this item. |

###

### Definitions: Single Call Entry

| Name        | Data Type | Value                                                                                              |
| ----------- | --------- | -------------------------------------------------------------------------------------------------- |
| dest        | string    | Destination phone number of the call.                                                              |
| src         | string    | <p>Source phone number of the call. </p><p>Outbound calls will be shown as "<em>Outbound</em>"</p> |
| start       | int       | Start UNIX timestamp for this call.                                                                |
| end         | int       | End Unix timestamp for this call.                                                                  |
| session\_id | string    | Unique ID for this call, also used to fetch individual call logs.                                  |
| type        | string    | Type for this call (*inbound*, *outbound* or *transfer*).                                          |
| log         | bool      | Flag indicating if a call log is available for this call.                                          |

###

### **Sample Code**

This sample PHP code makes a request to this method:

```php
<?php
// account and application settings
$email = '<your_email_address>';
$developer_key = '<your_developer_key>';
$start = strtotime('midnight -5 days);
$end = strtotime('midnight');
$number = '6177123000';
$limit = 10000;
$offset = 0;

// build the URL
$url = 'https://fuse.plumvoice.com/api/calls/'.$start.'/'.$end.'?number='.$number.'&limit='.$limit.'&offset='.$offset;

$ch = curl_init();
curl_setopt($ch, CURLOPT_USERPWD, $email.':'.$developer_key);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json"));
$result = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
var_dump($result);
var_dump($http_code);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.plumvoice.com/fuse/apis/logs/fetching-calls.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
