---
title: Get user facet info
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > Rum Audience Management
---

# Get user facet info{% #get-user-facet-info %}
Copy pageCopied
{% tab title="v2" %}
**Note**: This endpoint may be subject to changes.
| Datadog site      | API endpoint                                                                 |
| ----------------- | ---------------------------------------------------------------------------- |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v2/product-analytics/users/facet_info |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v2/product-analytics/users/facet_info |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v2/product-analytics/users/facet_info      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v2/product-analytics/users/facet_info      |
| us2.ddog-gov.com  | POST https://api.us2.ddog-gov.com/api/v2/product-analytics/users/facet_info  |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v2/product-analytics/users/facet_info     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v2/product-analytics/users/facet_info |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v2/product-analytics/users/facet_info |

### Overview

Get facet information for user attributes including possible values and counts

### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                      | Type   | Description                                                                                           |
| ------------ | -------------------------- | ------ | ----------------------------------------------------------------------------------------------------- |
|              | data                       | object | The data object containing the resource type and attributes for the facet info request.               |
| data         | attributes                 | object | Attributes for the facet info request, specifying which facet to query and optional filters to apply. |
| attributes   | facet_id [*required*] | string | The identifier of the facet attribute to retrieve value information for.                              |
| attributes   | limit [*required*]    | int64  | Maximum number of facet values to return in the response.                                             |
| attributes   | search                     | object | Query-based search configuration for filtering the audience context when retrieving facet values.     |
| search       | query                      | string | The filter expression used to scope the audience from which facet values are retrieved.               |
| attributes   | term_search                | object | Term-level search configuration for filtering facet values by an exact or partial term match.         |
| term_search  | value                      | string | The term string to match against facet values.                                                        |
| data         | id                         | string | Unique identifier for the facet info request resource.                                                |
| data         | type [*required*]     | enum   | Users facet info request resource type. Allowed enum values: `users_facet_info_request`               |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "facet_id": "",
      "limit": 0,
      "search": {
        "query": "string"
      },
      "term_search": {
        "value": "string"
      }
    },
    "id": "string",
    "type": "users_facet_info_request"
  }
}
```

{% /tab %}

### Response

{% tab title="200" %}
Successful response with facet information
{% tab title="Model" %}
Response containing facet information for an attribute, including its distinct values and occurrence counts.

| Parent field | Field                  | Type     | Description                                                                                         |
| ------------ | ---------------------- | -------- | --------------------------------------------------------------------------------------------------- |
|              | data                   | object   | The data object containing the resource type and attributes for the facet info response.            |
| data         | attributes             | object   | Attributes of the facet info response, containing the facet result data.                            |
| attributes   | result                 | object   | The facet query result containing discrete value counts or a numeric range for the requested facet. |
| result       | range                  | object   | The numeric range of a facet attribute, representing the minimum and maximum observed values.       |
| range        | max                    | object   | The maximum observed value for the numeric facet attribute.                                         |
| range        | min                    | object   | The minimum observed value for the numeric facet attribute.                                         |
| result       | values                 | [object] | List of discrete facet values with their occurrence counts.                                         |
| values       | count                  | int64    | The number of records that have this facet value.                                                   |
| values       | value                  | string   | The facet value (for example, a browser name or country code).                                      |
| data         | id                     | string   | Unique identifier for the facet info response resource.                                             |
| data         | type [*required*] | enum     | Users facet info resource type. Allowed enum values: `users_facet_info`                             |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "result": {
        "values": [
          {
            "count": 4892,
            "value": "Chrome"
          },
          {
            "count": 2341,
            "value": "Safari"
          },
          {
            "count": 1567,
            "value": "Firefox"
          },
          {
            "count": 892,
            "value": "Edge"
          },
          {
            "count": 234,
            "value": "Opera"
          }
        ]
      }
    },
    "id": "facet_info_response",
    "type": "users_facet_info"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \## default
# 
 \# Curl command curl -X POST "https://api.datadoghq.com/api/v2/product-analytics/users/facet_info" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "facet_id": "first_browser_name",
      "limit": 10,
      "search": {
        "query": "user_org_id:5001 AND first_country_code:US"
      },
      "term_search": {
        "value": "Chrome"
      }
    },
    "id": "facet_info_request",
    "type": "users_facet_info_request"
  }
}
EOF 
                
##### 

```python
"""
Get user facet info returns "Successful response with facet information" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.rum_audience_management_api import RumAudienceManagementApi
from datadog_api_client.v2.model.facet_info_request import FacetInfoRequest
from datadog_api_client.v2.model.facet_info_request_data import FacetInfoRequestData
from datadog_api_client.v2.model.facet_info_request_data_attributes import FacetInfoRequestDataAttributes
from datadog_api_client.v2.model.facet_info_request_data_attributes_search import FacetInfoRequestDataAttributesSearch
from datadog_api_client.v2.model.facet_info_request_data_attributes_term_search import (
    FacetInfoRequestDataAttributesTermSearch,
)
from datadog_api_client.v2.model.facet_info_request_data_type import FacetInfoRequestDataType

body = FacetInfoRequest(
    data=FacetInfoRequestData(
        attributes=FacetInfoRequestDataAttributes(
            facet_id="first_browser_name",
            limit=10,
            search=FacetInfoRequestDataAttributesSearch(
                query="user_org_id:5001 AND first_country_code:US",
            ),
            term_search=FacetInfoRequestDataAttributesTermSearch(
                value="Chrome",
            ),
        ),
        id="facet_info_request",
        type=FacetInfoRequestDataType.USERS_FACET_INFO_REQUEST,
    ),
)

configuration = Configuration()
configuration.unstable_operations["get_user_facet_info"] = True
with ApiClient(configuration) as api_client:
    api_instance = RumAudienceManagementApi(api_client)
    response = api_instance.get_user_facet_info(body=body)

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) and then save the example to `example.py` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
##### 

```ruby
# Get user facet info returns "Successful response with facet information" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.unstable_operations["v2.get_user_facet_info".to_sym] = true
end
api_instance = DatadogAPIClient::V2::RumAudienceManagementAPI.new

body = DatadogAPIClient::V2::FacetInfoRequest.new({
  data: DatadogAPIClient::V2::FacetInfoRequestData.new({
    attributes: DatadogAPIClient::V2::FacetInfoRequestDataAttributes.new({
      facet_id: "first_browser_name",
      limit: 10,
      search: DatadogAPIClient::V2::FacetInfoRequestDataAttributesSearch.new({
        query: "user_org_id:5001 AND first_country_code:US",
      }),
      term_search: DatadogAPIClient::V2::FacetInfoRequestDataAttributesTermSearch.new({
        value: "Chrome",
      }),
    }),
    id: "facet_info_request",
    type: DatadogAPIClient::V2::FacetInfoRequestDataType::USERS_FACET_INFO_REQUEST,
  }),
})
p api_instance.get_user_facet_info(body)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) and then save the example to `example.rb` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```go
// Get user facet info returns "Successful response with facet information" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)

func main() {
	body := datadogV2.FacetInfoRequest{
		Data: &datadogV2.FacetInfoRequestData{
			Attributes: &datadogV2.FacetInfoRequestDataAttributes{
				FacetId: "first_browser_name",
				Limit:   10,
				Search: &datadogV2.FacetInfoRequestDataAttributesSearch{
					Query: datadog.PtrString("user_org_id:5001 AND first_country_code:US"),
				},
				TermSearch: &datadogV2.FacetInfoRequestDataAttributesTermSearch{
					Value: datadog.PtrString("Chrome"),
				},
			},
			Id:   datadog.PtrString("facet_info_request"),
			Type: datadogV2.FACETINFOREQUESTDATATYPE_USERS_FACET_INFO_REQUEST,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("v2.GetUserFacetInfo", true)
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewRumAudienceManagementApi(apiClient)
	resp, r, err := api.GetUserFacetInfo(ctx, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `RumAudienceManagementApi.GetUserFacetInfo`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `RumAudienceManagementApi.GetUserFacetInfo`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) and then save the example to `main.go` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
##### 

```java
// Get user facet info returns "Successful response with facet information" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.RumAudienceManagementApi;
import com.datadog.api.client.v2.model.FacetInfoRequest;
import com.datadog.api.client.v2.model.FacetInfoRequestData;
import com.datadog.api.client.v2.model.FacetInfoRequestDataAttributes;
import com.datadog.api.client.v2.model.FacetInfoRequestDataAttributesSearch;
import com.datadog.api.client.v2.model.FacetInfoRequestDataAttributesTermSearch;
import com.datadog.api.client.v2.model.FacetInfoRequestDataType;
import com.datadog.api.client.v2.model.FacetInfoResponse;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setUnstableOperationEnabled("v2.getUserFacetInfo", true);
    RumAudienceManagementApi apiInstance = new RumAudienceManagementApi(defaultClient);

    FacetInfoRequest body =
        new FacetInfoRequest()
            .data(
                new FacetInfoRequestData()
                    .attributes(
                        new FacetInfoRequestDataAttributes()
                            .facetId("first_browser_name")
                            .limit(10L)
                            .search(
                                new FacetInfoRequestDataAttributesSearch()
                                    .query("user_org_id:5001 AND first_country_code:US"))
                            .termSearch(
                                new FacetInfoRequestDataAttributesTermSearch().value("Chrome")))
                    .id("facet_info_request")
                    .type(FacetInfoRequestDataType.USERS_FACET_INFO_REQUEST));

    try {
      FacetInfoResponse result = apiInstance.getUserFacetInfo(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling RumAudienceManagementApi#getUserFacetInfo");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=java) and then save the example to `Example.java` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
##### 

```rust
// Get user facet info returns "Successful response with facet information"
// response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_rum_audience_management::RumAudienceManagementAPI;
use datadog_api_client::datadogV2::model::FacetInfoRequest;
use datadog_api_client::datadogV2::model::FacetInfoRequestData;
use datadog_api_client::datadogV2::model::FacetInfoRequestDataAttributes;
use datadog_api_client::datadogV2::model::FacetInfoRequestDataAttributesSearch;
use datadog_api_client::datadogV2::model::FacetInfoRequestDataAttributesTermSearch;
use datadog_api_client::datadogV2::model::FacetInfoRequestDataType;

#[tokio::main]
async fn main() {
    let body = FacetInfoRequest::new().data(
        FacetInfoRequestData::new(FacetInfoRequestDataType::USERS_FACET_INFO_REQUEST)
            .attributes(
                FacetInfoRequestDataAttributes::new("first_browser_name".to_string(), 10)
                    .search(
                        FacetInfoRequestDataAttributesSearch::new()
                            .query("user_org_id:5001 AND first_country_code:US".to_string()),
                    )
                    .term_search(
                        FacetInfoRequestDataAttributesTermSearch::new().value("Chrome".to_string()),
                    ),
            )
            .id("facet_info_request".to_string()),
    );
    let mut configuration = datadog::Configuration::new();
    configuration.set_unstable_operation_enabled("v2.GetUserFacetInfo", true);
    let api = RumAudienceManagementAPI::with_config(configuration);
    let resp = api.get_user_facet_info(body).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) and then save the example to `src/main.rs` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
##### 

```typescript
/**
 * Get user facet info returns "Successful response with facet information" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
configuration.unstableOperations["v2.getUserFacetInfo"] = true;
const apiInstance = new v2.RumAudienceManagementApi(configuration);

const params: v2.RumAudienceManagementApiGetUserFacetInfoRequest = {
  body: {
    data: {
      attributes: {
        facetId: "first_browser_name",
        limit: 10,
        search: {
          query: "user_org_id:5001 AND first_country_code:US",
        },
        termSearch: {
          value: "Chrome",
        },
      },
      id: "facet_info_request",
      type: "users_facet_info_request",
    },
  },
};

apiInstance
  .getUserFacetInfo(params)
  .then((data: v2.FacetInfoResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) and then save the example to `example.ts` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
{% /tab %}
