> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# List users

GET https://api.elevenlabs.io/v1/convai/users

Get distinct users from conversations with pagination.

Reference: https://elevenlabs.io/docs/eleven-agents/api-reference/users/list

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: api
  version: 1.0.0
paths:
  /v1/convai/users:
    get:
      operationId: list
      summary: Get Conversation Users
      description: Get distinct users from conversations with pagination.
      tags:
        - subpackage_conversationalAi.subpackage_conversationalAi/users
      parameters:
        - name: agent_id
          in: query
          description: >-
            Agent id (agent_…) or speech engine external id (seng_), resolved to
            the same underlying resource.
          required: false
          schema:
            type: string
        - name: branch_id
          in: query
          description: Filter conversations by branch ID.
          required: false
          schema:
            type: string
        - name: call_start_before_unix
          in: query
          description: >-
            Unix timestamp (in seconds) to filter conversations up to this start
            date.
          required: false
          schema:
            type: integer
        - name: call_start_after_unix
          in: query
          description: >-
            Unix timestamp (in seconds) to filter conversations after to this
            start date.
          required: false
          schema:
            type: integer
        - name: search
          in: query
          description: Search/filter by user ID (exact match).
          required: false
          schema:
            type: string
        - name: page_size
          in: query
          description: How many users to return at maximum. Defaults to 30.
          required: false
          schema:
            type: integer
            default: 30
        - name: sort_by
          in: query
          description: >-
            The field to sort the results by. Defaults to
            last_contact_unix_secs.
          required: false
          schema:
            $ref: '#/components/schemas/type_:UsersSortBy'
        - name: cursor
          in: query
          description: Used for fetching next page. Cursor is returned in the response.
          required: false
          schema:
            type: string
        - name: xi-api-key
          in: header
          required: false
          schema:
            type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/type_:GetConversationUsersPageResponseModel
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:HTTPValidationError'
servers:
  - url: https://api.elevenlabs.io
  - url: https://api.us.elevenlabs.io
  - url: https://api.eu.residency.elevenlabs.io
  - url: https://api.in.residency.elevenlabs.io
components:
  schemas:
    type_:UsersSortBy:
      type: string
      enum:
        - last_contact_unix_secs
        - conversation_count
      title: UsersSortBy
    type_:ConversationUserResponseModel:
      type: object
      properties:
        user_id:
          type: string
        last_contact_unix_secs:
          type: integer
        first_contact_unix_secs:
          type: integer
        conversation_count:
          type: integer
        last_contact_agent_id:
          type: string
        last_contact_conversation_id:
          type: string
        last_contact_agent_name:
          type: string
      required:
        - user_id
        - last_contact_unix_secs
        - first_contact_unix_secs
        - conversation_count
        - last_contact_conversation_id
      title: ConversationUserResponseModel
    type_:GetConversationUsersPageResponseModel:
      type: object
      properties:
        users:
          type: array
          items:
            $ref: '#/components/schemas/type_:ConversationUserResponseModel'
        next_cursor:
          type: string
        has_more:
          type: boolean
      required:
        - users
        - has_more
      title: GetConversationUsersPageResponseModel
    type_:ValidationErrorLocItem:
      oneOf:
        - type: string
        - type: integer
      title: ValidationErrorLocItem
    type_:ValidationError:
      type: object
      properties:
        loc:
          type: array
          items:
            $ref: '#/components/schemas/type_:ValidationErrorLocItem'
        msg:
          type: string
        type:
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
    type_:HTTPValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/type_:ValidationError'
      title: HTTPValidationError

```

## SDK Code Examples

```typescript
import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";

async function main() {
    const client = new ElevenLabsClient();
    await client.conversationalAi.users.list({
        agentId: "agent_id",
        branchId: "branch_id",
        callStartBeforeUnix: 1,
        callStartAfterUnix: 1,
        search: "search",
        pageSize: 1,
        sortBy: "last_contact_unix_secs",
        cursor: "cursor",
    });
}
main();

```

```python
from elevenlabs import ElevenLabs

client = ElevenLabs()

client.conversational_ai.users.list(
    agent_id="agent_id",
    branch_id="branch_id",
    call_start_before_unix=1,
    call_start_after_unix=1,
    search="search",
    page_size=1,
    sort_by="last_contact_unix_secs",
    cursor="cursor",
)

```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.elevenlabs.io/v1/convai/users?agent_id=agent_id&branch_id=branch_id&call_start_before_unix=1&call_start_after_unix=1&search=search&page_size=1&sort_by=last_contact_unix_secs&cursor=cursor"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("GET", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.elevenlabs.io/v1/convai/users?agent_id=agent_id&branch_id=branch_id&call_start_before_unix=1&call_start_after_unix=1&search=search&page_size=1&sort_by=last_contact_unix_secs&cursor=cursor")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.elevenlabs.io/v1/convai/users?agent_id=agent_id&branch_id=branch_id&call_start_before_unix=1&call_start_after_unix=1&search=search&page_size=1&sort_by=last_contact_unix_secs&cursor=cursor")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.elevenlabs.io/v1/convai/users?agent_id=agent_id&branch_id=branch_id&call_start_before_unix=1&call_start_after_unix=1&search=search&page_size=1&sort_by=last_contact_unix_secs&cursor=cursor', [
  'body' => '{}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.elevenlabs.io/v1/convai/users?agent_id=agent_id&branch_id=branch_id&call_start_before_unix=1&call_start_after_unix=1&search=search&page_size=1&sort_by=last_contact_unix_secs&cursor=cursor");
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.elevenlabs.io/v1/convai/users?agent_id=agent_id&branch_id=branch_id&call_start_before_unix=1&call_start_after_unix=1&search=search&page_size=1&sort_by=last_contact_unix_secs&cursor=cursor")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```