> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-v6-beta2-flutter-uikit.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Call Logs

> Fetch, filter, and retrieve call history including duration, participants, and recording status using the CometChat Calls SDK.

<Accordion title="AI Integration Quick Reference">
  ```javascript theme={null}
  let loggedInUser = await CometChat.getLoggedinUser();
  let authToken = loggedInUser.getAuthToken();

  // Fetch call logs
  let request = new CometChatCalls.CallLogRequestBuilder()
    .setLimit(30)
    .setAuthToken(authToken)
    .setCallCategory("call")
    .build();

  let logs = await request.fetchNext();

  // Get details for a specific call session
  let details = await CometChatCalls.getCallDetails("SESSION_ID", authToken);
  ```

  **Filters:** `setCallType()`, `setCallStatus()`, `setCallCategory()`, `setCallDirection()`, `setHasRecording()`, `setUid()`, `setGuid()`
</Accordion>

Call logs let you retrieve and display call history — who called whom, when, how long, and whether it was recorded. Use `CallLogRequestBuilder` to fetch and filter logs, and `getCallDetails()` to get details for a specific session.

Before you begin, make sure you've completed the [Calls SDK Setup](/sdk/javascript/calling-setup).

## Fetch Call Logs

Build a request with `CallLogRequestBuilder`, then call `fetchNext()` or `fetchPrevious()` to retrieve logs. Call either method repeatedly on the same builder instance to paginate through results.

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    let callLogRequestBuilder: any = new CometChatCalls.CallLogRequestBuilder()
      .setLimit(30)
      .setAuthToken(loggedInUser.getAuthToken())
      .setCallCategory("call")
      .build();
    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={null}
    let callLogRequestBuilder = new CometChatCalls.CallLogRequestBuilder()
      .setLimit(30)
      .setAuthToken(loggedInUser.getAuthToken())
      .setCallCategory("call")
      .build();
    ```
  </Tab>
</Tabs>

### Builder Settings

| Setting                                                                                              | Description                                                  |
| ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| `setLimit(limit: number)`                                                                            | Specifies the number of call logs to fetch.                  |
| `setCallType(callType: 'video' or 'audio')`                                                          | Sets the type of calls to fetch (call or meet).              |
| `setCallStatus(callStatus: 'ongoing' or 'busy' or 'rejected' or 'cancelled' or 'ended' or 'missed')` | Sets the status of calls to fetch (initiated, ongoing, etc.) |
| `setHasRecording(hasRecording: boolean)`                                                             | Sets whether to fetch calls that have recordings.            |
| `setCallCategory(callCategory: 'call' or 'meet')`                                                    | Sets the category of calls to fetch (call or meet).          |
| `setCallDirection(callDirection: 'incoming' or 'outgoing')`                                          | Sets the direction of calls to fetch (incoming or outgoing)  |
| `setUid(uid: string)`                                                                                | Sets the UID of the user whose call logs to fetch.           |
| `setGuid(guid: string)`                                                                              | Sets the GUID of the user whose call logs to fetch.          |
| `setAuthToken(authToken: string)`                                                                    | Sets the Auth token of the logged-in user.                   |

### Fetch Next

Retrieves the next set of call logs:

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    let callLogRequestBuilder: any = new CometChatCalls.CallLogRequestBuilder()
      .setLimit(30)
      .setAuthToken(loggedInUser.getAuthToken())
      .setCallCategory("call")
      .build();

    callLogRequestBuilder.fetchNext().then(
      (callLogHistory: any[]) => {
        console.log(callLogHistory);
      },
      (err: any) => {
        console.log(err);
      }
    );
    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={null}
    let callLogRequestBuilder = new CometChatCalls.CallLogRequestBuilder()
      .setLimit(30)
      .setAuthToken(loggedInUser.getAuthToken())
      .setCallCategory("call")
      .build();

    callLogRequestBuilder.fetchNext().then(
      (callLogHistory) => {
        console.log(callLogHistory);
      },
      (err) => {
        console.log(err);
      }
    );
    ```
  </Tab>
</Tabs>

### Fetch Previous

Retrieves the previous set of call logs:

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    let callLogRequestBuilder: any = new CometChatCalls.CallLogRequestBuilder()
      .setLimit(30)
      .setAuthToken(loggedInUser.getAuthToken())
      .setCallCategory("call")
      .build();

    callLogRequestBuilder.fetchPrevious().then(
      (callLogHistory: any[]) => {
        console.log(callLogHistory);
      },
      (err: any) => {
        console.log(err);
      }
    );
    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={null}
    let callLogRequestBuilder = new CometChatCalls.CallLogRequestBuilder()
      .setLimit(30)
      .setAuthToken(loggedInUser.getAuthToken())
      .setCallCategory("call")
      .build();

    callLogRequestBuilder.fetchPrevious().then(
      (callLogHistory) => {
        console.log(callLogHistory);
      },
      (err) => {
        console.log(err);
      }
    );
    ```
  </Tab>
</Tabs>

The `fetchNext()` and `fetchPrevious()` methods return an array of [`CallLog`](/sdk/reference/calls#calllog) objects.

## Get Call Details

Retrieve details for a specific call session using `getCallDetails()`:

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    const sessionID: string = "SESSION_ID";
    CometChatCalls.getCallDetails(sessionID, authToken).then(
      (callLogs: Array<CallLog>) => {
        console.log("Call details:", callLogs);
      },
      (error: any) => {
        console.log("Error fetching call details:", error);
      }
    );
    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={null}
    const sessionID = "SESSION_ID";
    CometChatCalls.getCallDetails(sessionID, authToken).then(
      (callLogs) => {
        console.log("Call details:", callLogs);
      },
      (error) => {
        console.log("Error fetching call details:", error);
      }
    );
    ```

    Alternatively, you can use the `async/await` syntax:

    ```javascript theme={null}
    const sessionID = "SESSION_ID";
    try {
      const callLogs = await CometChatCalls.getCallDetails(sessionID, authToken);
      console.log("Call details:", callLogs);
    } catch (error) {
      console.log("Error fetching call details:", error);
    }
    ```
  </Tab>
</Tabs>

Note: Replace `"SESSION_ID"` with the ID of the session you are interested in.

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Default Calling" icon="phone-volume" href="/sdk/javascript/default-call">
    Implement the complete ringing call flow
  </Card>

  <Card title="Recording" icon="circle-dot" href="/sdk/javascript/recording">
    Record audio and video calls
  </Card>

  <Card title="Direct Calling" icon="video" href="/sdk/javascript/direct-call">
    Start call sessions without the ringing flow
  </Card>

  <Card title="Calling Setup" icon="gear" href="/sdk/javascript/calling-setup">
    Install and initialize the Calls SDK
  </Card>
</CardGroup>
