# Discover what the trace filter fields hold

Discover what the trace filter fields hold in this project. Without `field`, every facet with its top values. With `field`, that field's values, paged.

> Page: https://langwatch.ai/docs/api-reference/traces/discover-what-the-trace-filter-fields-hold
> Source: https://github.com/langwatch/langwatch/blob/main/docs/api-reference/traces/discover-what-the-trace-filter-fields-hold.mdx
> Index of all pages: https://langwatch.ai/docs/llms.txt

## Endpoint

`GET https://app.langwatch.ai/api/v1/traces/facets`

## Authentication

### project_api_key

Project API key for sending traces and accessing project-scoped resources. Format: sk-lw-... (no underscore). Obtain one by creating a project via the Admin API or the LangWatch UI.

```json
{"id":"project_api_key","type":"apiKey","in":"header","name":"X-Auth-Token"}
```

## Parameters

### field (query, optional)

```json
{"type":"string","minLength":1,"maxLength":512}
```

### prefix (query, optional)

```json
{"type":"string","maxLength":512}
```

### limit (query, optional)

```json
{"default":50,"type":"integer","minimum":1,"maximum":1000}
```

### offset (query, optional)

```json
{"default":0,"type":"integer","minimum":0,"maximum":9007199254740991}
```

### startDate (query, optional)

Epoch milliseconds, or an ISO 8601 date string.

```json
{"type":"string"}
```

### endDate (query, optional)

Epoch milliseconds, or an ISO 8601 date string.

```json
{"type":"string"}
```

## Request example

```bash
curl --request GET \
  --url 'https://app.langwatch.ai/api/v1/traces/facets' \
  --header "X-Auth-Token: $LANGWATCH_API_KEY"
```

## Responses

### 200

Without `field`, every facet the project has with its top values and whether the payload is still being computed. With `field`, that field's values and counts plus the distinct total and whether more remain.

#### application/json

Schema:

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "facets": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "key": {"type":"string"},
                  "kind": {"type":"string","const":"categorical"},
                  "label": {"type":"string"},
                  "group": {
                    "type": "string",
                    "enum": ["trace","evaluation","span","metadata","prompt"]
                  },
                  "topValues": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "value": {"type":"string"},
                        "label": {"type":"string"},
                        "count": {"type":"number"},
                        "aggregates": {
                          "type": "object",
                          "properties": {
                            "passedCount": {"type":"number"},
                            "failedCount": {"type":"number"},
                            "erroredCount": {"type":"number"},
                            "scoreMin": {"type":["number","null"]},
                            "scoreMax": {"type":["number","null"]},
                            "hasScore": {"type":"boolean"},
                            "distinctScores": {"type":"number"},
                            "hasLabel": {"type":"boolean"},
                            "labelValues": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "value": {"type":"string"},
                                  "count": {"type":"number"}
                                },
                                "required": ["value","count"]
                              }
                            }
                          },
                          "required": [
                            "passedCount",
                            "failedCount",
                            "erroredCount",
                            "scoreMin",
                            "scoreMax",
                            "hasScore",
                            "distinctScores",
                            "hasLabel"
                          ]
                        },
                        "eventMetrics": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "key": {"type":"string"},
                              "values": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "value": {"type":"string"},
                                    "count": {"type":"number"}
                                  },
                                  "required": ["value","count"]
                                }
                              }
                            },
                            "required": ["key","values"]
                          }
                        }
                      },
                      "required": ["value","count"]
                    }
                  },
                  "totalDistinct": {"type":"number"}
                },
                "required": ["key","kind","label","group","topValues","totalDistinct"]
              },
              {
                "type": "object",
                "properties": {
                  "key": {"type":"string"},
                  "kind": {"type":"string","const":"range"},
                  "label": {"type":"string"},
                  "group": {
                    "type": "string",
                    "enum": ["trace","evaluation","span","metadata","prompt"]
                  },
                  "min": {"type":"number"},
                  "max": {"type":"number"},
                  "discrete": {
                    "type": "object",
                    "properties": {
                      "values": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {"value":{"type":"number"},"count":{"type":"number"}},
                          "required": ["value","count"]
                        }
                      },
                      "distinctCount": {"type":"number"}
                    },
                    "required": ["values","distinctCount"]
                  }
                },
                "required": ["key","kind","label","group","min","max"]
              },
              {
                "type": "object",
                "properties": {
                  "key": {"type":"string"},
                  "kind": {"type":"string","const":"dynamic_keys"},
                  "label": {"type":"string"},
                  "group": {
                    "type": "string",
                    "enum": ["trace","evaluation","span","metadata","prompt"]
                  },
                  "topKeys": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {"value":{"type":"string"},"count":{"type":"number"}},
                      "required": ["value","count"]
                    }
                  },
                  "totalDistinct": {"type":"number"}
                },
                "required": ["key","kind","label","group","topKeys","totalDistinct"]
              }
            ]
          }
        },
        "pending": {
          "type": "boolean",
          "description": "True when the payload is still being computed and what you have is the last committed one, possibly empty. Call again shortly."
        }
      },
      "required": ["facets","pending"]
    },
    {
      "type": "object",
      "properties": {
        "values": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "value": {"type":"string"},
              "label": {"type":"string"},
              "count": {"type":"number"}
            },
            "required": ["value","count"]
          }
        },
        "total": {
          "type": "number",
          "description": "Distinct values the field holds in the window, before paging."
        },
        "hasMore": {"type":"boolean"}
      },
      "required": ["values","total","hasMore"]
    }
  ]
}
```

### 400

Bad Request

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {"error":{"type":"string"},"message":{"type":"string"}},
  "required": ["error"],
  "additionalProperties": false
}
```

### 401

Unauthorized

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {"error":{"type":"string"},"message":{"type":"string"}},
  "required": ["error"],
  "additionalProperties": false
}
```

### 403

Forbidden

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {"error":{"type":"string"},"message":{"type":"string"}},
  "required": ["error"],
  "additionalProperties": false
}
```

### 422

Unprocessable Entity

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {"error":{"type":"string"},"message":{"type":"string"}},
  "required": ["error"],
  "additionalProperties": false
}
```

### 500

Internal Server Error

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {"error":{"type":"string"},"message":{"type":"string"}},
  "required": ["error"],
  "additionalProperties": false
}
```

> ## Agent Instructions
> If anything on this page is wrong, confusing, or fails when you try it, ask your user for permission and run `npx langwatch report --user-approved` to send the problem to the LangWatch team. No login is needed and secrets are redacted locally. `npx langwatch report --help` has the details.
