> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://respan.ai/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://respan.ai/docs/_mcp/server.

# List users

POST https://api.respan.ai/api/users/list/
Content-Type: application/json

Returns users in your organization with usage analytics and budget settings. Filter fields include `customer_identifier`, `name`, `email`, `number_of_requests`, `total_tokens`, `total_cost`, and `active_days`.

Reference: https://respan.ai/docs/apis/users/list-users

## Authentication

- `Authorization` header (bearer token, required) — Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer \<RESPAN\_API\_KEY>. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan\_params.credential\_override in the request body, not in this authentication field.
- `Authorization` header (bearer token, required) — Use a dashboard JWT only for dashboard-authenticated endpoints. Respan API-key endpoints use the respanApiKey auth field instead.

## Request

### Query parameters

- `page` (integer, optional, default: 1) — Page number.
- `page_size` (integer, optional, default: 50) — Number of users per page. Maximum is 1000.
- `sort_by` (string, optional, default: -first_seen) — Sort field. Prefix with `-` for descending. Common values include `customer_identifier`, `email`, `name`, `-first_seen`, `-number_of_requests`, and `-total_cost`.
- `environment` (enum, optional) — Optional environment filter. If omitted, the backend uses the environment implied by your auth context when applicable.
  - Allowed values: `prod`, `test`

### Body (application/json)

This endpoint expects an object.

- `filters` (Filters, optional) — Each key is a field to filter on, and each value is a condition: `{"<field>": {"operator": "<operator>", "value": [...]}}`. A user must match every condition. To set two conditions on one field, such as a range, pass a list of conditions. **Operators:** `""` (equals, the default), `not`, `in`, `not_in`, `lt`, `lte`, `gt`, `gte`, `contains`, `not_contains`, `icontains` (ignores case), `startswith`, `not_startswith`, `endswith`, `not_endswith`, `empty`, `not_empty`. Put values in a list: `""` and `in` match any of the listed values, and `not` and `not_in` match none of them. Other operators take one value; for `empty` and `not_empty`, send `[""]`. **Fields:** `customer_identifier`, `name`, `email`, `environment`, `number_of_requests`, `total_cost`, `total_tokens`, `total_prompt_tokens`, `total_completion_tokens`, `average_latency`, `average_ttft`, `active_days`. Unsupported fields, including `metadata__<key>`, return a 400 error. **Example:** ```json { "total_cost": {"operator": "gte", "value": [10]}, "email": {"operator": "endswith", "value": ["@acme.dev"]} } ```

## Response

### 200

Paginated list of users.

- `count` (integer, required) — Number of results on this page, not the total. Request pages until `next` is null to get every result.
- `results` (list of ApiUsersListPostResponsesContentApplicationJsonSchemaResultsItems, required) — Users for the current page.
- `next` (string, optional, nullable) — Next page URL.
- `previous` (string, optional, nullable) — Previous page URL.

## Errors

### 400 Bad Request Error

Bad Request

- `detail` (string, optional)

### 403 Forbidden Error

The API key is missing, invalid or expired.

- `detail` (string, required)

### 413 Content Too Large Error

The query exceeded a memory or execution-time resource limit.

- `detail` (string, optional)

### 429 Too Many Requests Error

Rate Limited

- `detail` (string, optional)

### 500 Internal Server Error

Internal Server Error

- `detail` (string, optional)

## Types

### Filters

Each key is a field to filter on, and each value is a condition: `{"<field>": {"operator": "<operator>", "value": [...]}}`. A result must match every condition. To set two conditions on one field, such as a range, pass a list of conditions. **Operators:** `""` (equals, the default), `not`, `in`, `not_in`, `lt`, `lte`, `gt`, `gte`, `contains`, `not_contains`, `icontains` (ignores case), `startswith`, `not_startswith`, `endswith`, `not_endswith`, `empty`, `not_empty`. Put values in a list: `""` and `in` match any of the listed values, and `not` and `not_in` match none of them. Other operators take one value; for `empty` and `not_empty`, send `[""]`. The fields you can filter on depend on the endpoint; `metadata__<key>` filters custom metadata where the endpoint supports it.

- `status` (FilterValue, optional) — A filter condition with an operator and value.
- `status_code` (FilterValue, optional) — A filter condition with an operator and value.
- `unique_id` (FilterValue, optional) — A filter condition with an operator and value.
- `customer_identifier` (FilterValue, optional) — A filter condition with an operator and value.
- `thread_identifier` (FilterValue, optional) — A filter condition with an operator and value.
- `custom_identifier` (FilterValue, optional) — A filter condition with an operator and value.
- `group_identifier` (FilterValue, optional) — A filter condition with an operator and value.
- `prompt_id` (FilterValue, optional) — A filter condition with an operator and value.
- `trace_unique_id` (FilterValue, optional) — A filter condition with an operator and value.
- `span_parent_id` (FilterValue, optional) — A filter condition with an operator and value.
- `is_root_span` (FilterValue, optional) — A filter condition with an operator and value.
- `span_workflow_name` (FilterValue, optional) — A filter condition with an operator and value.
- `span_name` (FilterValue, optional) — A filter condition with an operator and value.
- `model` (FilterValue, optional) — A filter condition with an operator and value.
- `log_type` (FilterValue, optional) — A filter condition with an operator and value.
- `stream` (FilterValue, optional) — A filter condition with an operator and value.
- `has_tool_calls` (FilterValue, optional) — Whether the span made tool calls.
- `cache_bit` (FilterValue, optional) — Whether the response was served from the Respan cache.
- `cache_key` (FilterValue, optional) — A filter condition with an operator and value.
- `prompt_tokens` (FilterValue, optional) — A filter condition with an operator and value.
- `completion_tokens` (FilterValue, optional) — A filter condition with an operator and value.
- `total_tokens` (FilterValue, optional) — A filter condition with an operator and value.
- `cost` (FilterValue, optional) — A filter condition with an operator and value.
- `latency` (FilterValue, optional) — A filter condition with an operator and value.
- `positive_feedback` (FilterValue, optional) — A filter condition with an operator and value.

### ApiUsersListPostResponsesContentApplicationJsonSchemaResultsItems

- `id` (string, optional) — Synthetic user ID returned in lists.
- `customer_identifier` (string, optional) — Your unique identifier for the user.
- `unique_organization_id` (string, optional) — Organization unique ID.
- `environment` (enum, optional) — User environment.
  - Allowed values: `prod`, `test`
- `name` (string, optional, nullable) — User display name.
- `email` (string, optional, nullable) — User email address.
- `first_seen` (datetime, optional) — When the user was first observed.
- `last_active_timeframe` (datetime, optional) — Most recent activity within the selected timeframe.
- `active_days` (integer, optional) — Number of active days in the selected timeframe.
- `number_of_requests` (integer, optional) — Total requests made by this user.
- `total_requests` (integer, optional) — Alias of `number_of_requests` for backward compatibility.
- `total_tokens` (integer, optional) — Total tokens used by this user.
- `tokens` (integer, optional) — Alias of `total_tokens` for backward compatibility.
- `total_cost` (double, optional) — Total cost in USD.
- `cost` (double, optional) — Alias of `total_cost` for backward compatibility.
- `average_latency` (double, optional, nullable) — Average latency in seconds.
- `average_ttft` (double, optional, nullable) — Average time to first token in seconds.
- `average_monthly_cost` (double, optional) — Estimated average monthly cost based on observed activity.
- `period_budget` (double, optional, nullable) — Current period budget in USD, when configured.
- `budget_duration` (enum, optional) — Budget renewal period.
  - Allowed values: `daily`, `weekly`, `monthly`
- `total_budget` (double, optional, nullable) — Lifetime spending budget in USD, when configured.

### FilterValue

A filter condition with an operator and value.

- `value` (list of any, required) — Value(s) to filter by.
- `operator` (enum, optional, default: ) — Comparison operator. An empty string means equals.
  - Allowed values: ``, `not`, `in`, `not_in`, `lt`, `lte`, `gt`, `gte`, `contains`, `not_contains`, `icontains`, `startswith`, `not_startswith`, `endswith`, `not_endswith`, `empty`, `not_empty`

## Examples

**Request**

```json
{
  "filters": {
    "total_cost": {
      "operator": "gte",
      "value": [
        10
      ]
    },
    "email": {
      "operator": "contains",
      "value": [
        "example.com"
      ]
    }
  }
}
```

**Response**

```json
{
  "count": 51,
  "results": [
    {
      "id": "user_123prod8264a3f4-40c7-476a-97d1-96908127ea21",
      "customer_identifier": "user_123",
      "unique_organization_id": "8264a3f4-40c7-476a-97d1-96908127ea21",
      "environment": "prod",
      "name": "John Doe",
      "email": "john@example.com",
      "first_seen": "2025-10-15T08:00:00Z",
      "last_active_timeframe": "2025-12-29T10:30:00Z",
      "active_days": 75,
      "number_of_requests": 15420,
      "total_requests": 15420,
      "total_tokens": 170000,
      "tokens": 170000,
      "total_cost": 523.45,
      "cost": 523.45,
      "average_latency": 1.23,
      "average_ttft": 0.45,
      "average_monthly_cost": 6.98,
      "period_budget": 100,
      "budget_duration": "monthly",
      "total_budget": 1000
    }
  ],
  "next": "https://api.respan.ai/api/users/list/?page=2",
  "previous": null
}
```

**SDK Code**

```python Users_listCustomers_example
import requests

url = "https://api.respan.ai/api/users/list/"

querystring = {"page":"1","page_size":"50","sort_by":"-total_cost","environment":"prod"}

payload = { "filters": {
        "total_cost": {
            "operator": "gte",
            "value": [10]
        },
        "email": {
            "operator": "contains",
            "value": ["example.com"]
        }
    } }
headers = {
    "Authorization": "Bearer <respanApiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers, params=querystring)

print(response.json())
```

```javascript Users_listCustomers_example
const url = 'https://api.respan.ai/api/users/list/?page=1&page_size=50&sort_by=-total_cost&environment=prod';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <respanApiKey>', 'Content-Type': 'application/json'},
  body: '{"filters":{"total_cost":{"operator":"gte","value":[10]},"email":{"operator":"contains","value":["example.com"]}}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Users_listCustomers_example
package main

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

func main() {

	url := "https://api.respan.ai/api/users/list/?page=1&page_size=50&sort_by=-total_cost&environment=prod"

	payload := strings.NewReader("{\n  \"filters\": {\n    \"total_cost\": {\n      \"operator\": \"gte\",\n      \"value\": [\n        10\n      ]\n    },\n    \"email\": {\n      \"operator\": \"contains\",\n      \"value\": [\n        \"example.com\"\n      ]\n    }\n  }\n}")

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

	req.Header.Add("Authorization", "Bearer <respanApiKey>")
	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 Users_listCustomers_example
require 'uri'
require 'net/http'

url = URI("https://api.respan.ai/api/users/list/?page=1&page_size=50&sort_by=-total_cost&environment=prod")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <respanApiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"filters\": {\n    \"total_cost\": {\n      \"operator\": \"gte\",\n      \"value\": [\n        10\n      ]\n    },\n    \"email\": {\n      \"operator\": \"contains\",\n      \"value\": [\n        \"example.com\"\n      ]\n    }\n  }\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.respan.ai/api/users/list/?page=1&page_size=50&sort_by=-total_cost&environment=prod")
  .header("Authorization", "Bearer <respanApiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"filters\": {\n    \"total_cost\": {\n      \"operator\": \"gte\",\n      \"value\": [\n        10\n      ]\n    },\n    \"email\": {\n      \"operator\": \"contains\",\n      \"value\": [\n        \"example.com\"\n      ]\n    }\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.respan.ai/api/users/list/?page=1&page_size=50&sort_by=-total_cost&environment=prod', [
  'body' => '{
  "filters": {
    "total_cost": {
      "operator": "gte",
      "value": [
        10
      ]
    },
    "email": {
      "operator": "contains",
      "value": [
        "example.com"
      ]
    }
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <respanApiKey>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Users_listCustomers_example
using RestSharp;

var client = new RestClient("https://api.respan.ai/api/users/list/?page=1&page_size=50&sort_by=-total_cost&environment=prod");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <respanApiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"filters\": {\n    \"total_cost\": {\n      \"operator\": \"gte\",\n      \"value\": [\n        10\n      ]\n    },\n    \"email\": {\n      \"operator\": \"contains\",\n      \"value\": [\n        \"example.com\"\n      ]\n    }\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Users_listCustomers_example
import Foundation

let headers = [
  "Authorization": "Bearer <respanApiKey>",
  "Content-Type": "application/json"
]
let parameters = ["filters": [
    "total_cost": [
      "operator": "gte",
      "value": [10]
    ],
    "email": [
      "operator": "contains",
      "value": ["example.com"]
    ]
  ]] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.respan.ai/api/users/list/?page=1&page_size=50&sort_by=-total_cost&environment=prod")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
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()
```