# Get call history

{% hint style="info" %}
**Note:**

* For APIs used for Shop, the API key is: [`<api_key>`](/api-etelecom-english/api-integration/shop/account.md). The base\_url information of the [Shop](/api-etelecom-english/api-integration/shop/account.md).
* For APIs used for Partner, the API key is: [`<shop_key>`](/api-etelecom-english/api-integration/partner/usage.md#retrieve-the-shop_key-information). The base\_url information of the [Partner](/api-etelecom-english/api-integration/partner/account.md).
  {% endhint %}

{% openapi src="/files/98tvgFAALfk6gcxXW2re" path="$BASE\_URL.ETelecom/ListCallLogs" method="post" %}
[Etelecom.swagger.json](https://1712041776-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzzTMjVbVjwTuSbEGC7Ya%2Fuploads%2FWUFJEkkaHbapFqmvlAg4%2FEtelecom.swagger.json?alt=media\&token=3bf6fc05-db9d-47eb-a46e-a57b6619adbb)
{% endopenapi %}

**Request:**

```
curl --location '$BASE_URL.Etelecom/ListCallLogs' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer $API-KEY' \
--data '{
  "filter": {
    "call_number": "<string>",
    "call_state": "not_answered",
    "date_from": "<dateTime>",
    "date_to": "<dateTime>",
    "department_id": "<int64>",
    "direction": "in",
    "duration": {
      "comparison": "less_than_or_equal_to",
      "value": "<integer>"
    },
    "extension_ids": [
      "<int64>",
      "<int64>"
    ],
    "external_id": "<string>",
    "external_session_id": "<string>",
    "hotline_ids": [
      "<int64>",
      "<int64>"
    ],
    "user_id": "<int64>"
  },
  "paging": {
    "after": "<string>",
    "before": "<string>",
    "limit": "<integer>",
    "sort": "<string>"
  }
}'
```

**Response:**

```
{
  "call_logs": [
    {
      "call_state": "unknown",
      "call_status": "Z",
      "call_targets": [
        {
          "add_time": "2019-08-24T14:15:22Z",
          "answered_time": "2019-08-24T14:15:22Z",
          "end_reason": "string",
          "ended_time": "2019-08-24T14:15:22Z",
          "fail_code": 0,
          "ring_duration": 0,
          "ring_time": "2019-08-24T14:15:22Z",
          "status": "string",
          "target_number": "string",
          "trunk_name": "string"
        }
      ],
      "callee": "string",
      "caller": "string",
      "contact_id": "string",
      "created_at": "2019-08-24T14:15:22Z",
      "direction": "unknown",
      "duration": 0,
      "ended_at": "2019-08-24T14:15:22Z",
      "extension_id": "string",
      "external_id": "string",
      "external_session_id": "string",
      "id": "string",
      "note": "string",
      "recording_urls": [
        "string"
      ],
      "started_at": "2019-08-24T14:15:22Z",
      "updated_at": "2019-08-24T14:15:22Z",
      "user_id": "string"
    }
  ],
  "paging": {
    "after": "string",
    "before": "string",
    "limit": 0,
    "next": "string",
    "prev": "string",
    "sort": "string"
  }
}
```

**Request body structure:**

| School name           | Data type | Describe                                           |
| --------------------- | --------- | -------------------------------------------------- |
| extension\_ids        | string\[] | List of extensions                                 |
| extension\_ids        | string    | Calling number                                     |
| hotline\_ids          | string\[] | Hotline list                                       |
| call\_state           | enum      | Call status ( `unknown` `answered` `not_answered`) |
| date\_from            | string    | Start date (eg: "2021-03-10T17:07:19+07:00")       |
| date\_to              | string    | End date (eg: "2021-03-10T17:07:19+07:00")         |
| external\_id          | string    | Get it when making a call on web/mobile            |
| external\_session\_id | string    | Get it when making a call on web/mobile            |

**Return data attribute structure:**

| School name     | Data type | Describe                                                        |
| --------------- | --------- | --------------------------------------------------------------- |
| extension\_id   | string    | Extension Id                                                    |
| silence         | string    | Recipient phone number                                          |
| caller          | string    | Caller phone number                                             |
| direction       | enum      | Call direction ( `unknown` `in` `out` `ext` `ext_in` `ext_out`) |
| call\_targets   | array     | List of related extensions                                      |
| recording\_urls | array     | Recording file                                                  |

**Note** :

* Response is returned in paginated fashion. Typically: `100`elements (call logs) / pages sorted by newest, pass `limit`if changes are desired.
* The response returned will be accompanied by`paging`
* Passing `next`the query string `after`in the above request will get the next page, conversely passing `prev`the query string `after`in the above request will get the previous page (if any).


---

# 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.etelecom.vn/api-etelecom-english/api-integration/vpbx/pbx-rest-apis/get-call-history.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.
