> For the complete documentation index, see [llms.txt](https://user.netmera.com/netmera-developer-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://user.netmera.com/netmera-developer-guide/api-documentation/api-reference/segments-and-targeting/count-targeted-users.md). Agents can also search and read this documentation through its [MCP server](https://user.netmera.com/netmera-developer-guide/~gitbook/mcp).

# Count Targeted Users

Returns the number of unique users who match a targeting query. Use it for popularity and adoption metrics based on profile data, without exporting user lists or building your own aggregation pipelines.

#### Capabilities

* **Social proof** — Show how many users chose, follow or like something.
* **Entity popularity** — Count favorites, preferences, interests or affinity per entity.
* **Content and product popularity** — Count interest in content, products, categories or brands.

#### How it works

`target` follows Netmera's standard targeting format. All parts that are sent are combined with AND:

* **`profile`** — Profile attribute names, matched with a single value, several values (at least one must match) or operators such as `$exists`. Single-value and array attributes are handled the same way.
* **`tag`** — A tag name, an array of names matched with OR, or an object with `$and`, `$or` or `$not`.
* **`segment`** — A segment name, an array of names matched with OR, or an object with `$and` or `$not`.
* **`location`** — `latitude`, `longitude` and `radius` in kilometres, all numeric.

<details>

<summary>Notes</summary>

* Counts can be up to 2–3 hours old. They come from aggregation and caching, and the cache duration adapts to system load.
* Real-time results are not guaranteed, but freshness is sufficient for social proof and popularity.
* Counts match the Netmera panel when the targeting is identical.
* The count reflects users matching at query time. The delivery audience of a message can differ slightly because of conditions applied at send time.
* Only counts are returned; user lists are not exposed.
* Attributes must be defined and active in the Netmera panel.
* Tag, segment and profile attribute names are matched exactly, including letter case and spaces. An unknown name returns HTTP 400, code 2009.
* Profile attributes are referenced by name. The `and`/`or` keywords themselves are case-insensitive.
* Query several values in one request when possible.
* Avoid polling the same entity repeatedly, and cache frequently displayed counts on your side.

</details>

```json
{"openapi":"3.1.0","info":{"title":"Netmera REST API","version":"3.0"},"tags":[{"name":"Segments and Targeting","description":"List and manage segments, read their users, and count how many users a target reaches before you\nsend.\n\n<table data-view=\"cards\"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type=\"content-ref\"></th></tr></thead><tbody><tr><td><strong>List Segments</strong></td><td><code>GET</code> Lists the segments defined in the panel.</td><td><a href=\"https://user.netmera.com/netmera-developer-guide/api-documentation/api-reference/segments-and-targeting/list-segments\">List Segments</a></td></tr><tr><td><strong>Get Segment</strong></td><td><code>GET</code> Returns the status and the user count of a segment.</td><td><a href=\"https://user.netmera.com/netmera-developer-guide/api-documentation/api-reference/segments-and-targeting/get-segment\">Get Segment</a></td></tr><tr><td><strong>List Segment Users</strong></td><td><code>GET</code> Returns the users in a segment, one page at a time.</td><td><a href=\"https://user.netmera.com/netmera-developer-guide/api-documentation/api-reference/segments-and-targeting/list-segment-users\">List Segment Users</a></td></tr><tr><td><strong>Create Segment</strong></td><td><code>POST</code> Creates a standard (condition-based) segment.</td><td><a href=\"https://user.netmera.com/netmera-developer-guide/api-documentation/api-reference/segments-and-targeting/create-segment\">Create Segment</a></td></tr><tr><td><strong>Update Segment</strong></td><td><code>POST</code> Replaces the conditions of a segment and calculates it again.</td><td><a href=\"https://user.netmera.com/netmera-developer-guide/api-documentation/api-reference/segments-and-targeting/update-segment\">Update Segment</a></td></tr><tr><td><strong>Change Segment Status</strong></td><td><code>POST</code> Deletes a segment, or reopens a deleted one.</td><td><a href=\"https://user.netmera.com/netmera-developer-guide/api-documentation/api-reference/segments-and-targeting/change-segment-status\">Change Segment Status</a></td></tr><tr><td><strong>Count Targeted Users</strong></td><td><code>POST</code> Returns the number of unique users who match a targeting query.</td><td><a href=\"https://user.netmera.com/netmera-developer-guide/api-documentation/api-reference/segments-and-targeting/count-targeted-users\">Count Targeted Users</a></td></tr><tr><td><strong>Count Users per Attribute Value</strong></td><td><code>POST</code> Returns the distinct user count for every value of one profile or installation attribute in a single request.</td><td><a href=\"https://user.netmera.com/netmera-developer-guide/api-documentation/api-reference/segments-and-targeting/count-users-per-attribute-value\">Count Users per Attribute Value</a></td></tr><tr><td><strong>Count Users with Push Permission</strong></td><td><code>GET</code> Returns the number of users in your application who currently have push permission.</td><td><a href=\"https://user.netmera.com/netmera-developer-guide/api-documentation/api-reference/segments-and-targeting/count-users-with-push-permission\">Count Users with Push Permission</a></td></tr></tbody></table>\n"}],"servers":[{"url":"https://restapi.netmera.com","description":"Netmera REST API"}],"security":[{"REST-API-key":[]}],"components":{"securitySchemes":{"REST-API-key":{"type":"apiKey","in":"header","name":"X-netmera-api-key","description":"REST API key. Available in the Netmera Panel under Developers > API.\n"}},"schemas":{"TargetOperatorList":{"description":"A single value, an array of values (OR), or an operator object using `$or`, `$and` or\n`$not`.\n","oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}},{"type":"object","properties":{"$or":{"type":"array","items":{"type":"string"}},"$and":{"type":"array","items":{"type":"string"}},"$not":{"type":"array","items":{"type":"string"}}},"additionalProperties":true}]},"Location":{"type":"object","description":"Geographical area used to target users based on their location.","required":["latitude","longitude","radius"],"properties":{"latitude":{"type":"number","description":"The latitude of the center point."},"longitude":{"type":"number","description":"The longitude of the center point."},"radius":{"type":"number","description":"The radius value, in kilometers, from the center to search for users.\n"}}},"NetmeraError":{"type":"object","description":"Standard Netmera error body.","required":["code","error"],"properties":{"code":{"type":"integer","description":"Netmera error code. See the error table in the API description."},"error":{"type":"string","description":"Human readable error message."}}}},"responses":{"InvalidApiKey":{"description":"The `X-netmera-api-key` header is missing or the key is not valid.\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NetmeraError"}}}},"IpNotAllowed":{"description":"The application restricts REST calls to a list of allowed IP addresses and the caller's\nIP is not on it. The check runs after the API key is validated and before the request\nbody and parameters are validated, so a restricted application returns this error even\nfor a malformed request.\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NetmeraError"}}}}}},"paths":{"/rest/3.0/targeting/count":{"post":{"operationId":"targetingCount","tags":["Segments and Targeting"],"summary":"Count Targeted Users","description":"Returns the number of unique users who match a targeting query. Use it for popularity and adoption\nmetrics based on profile data, without exporting user lists or building your own aggregation\npipelines.\n\n### Capabilities\n\n- **Social proof** — Show how many users chose, follow or like something.\n- **Entity popularity** — Count favorites, preferences, interests or affinity per entity.\n- **Content and product popularity** — Count interest in content, products, categories or brands.\n\n### How it works\n\n`target` follows Netmera's standard targeting format. All parts that are sent are combined with AND:\n- **`profile`** — Profile attribute names, matched with a single value, several values (at least one\n  must match) or operators such as `$exists`. Single-value and array attributes are handled the same\n  way.\n- **`tag`** — A tag name, an array of names matched with OR, or an object with `$and`, `$or` or\n  `$not`.\n- **`segment`** — A segment name, an array of names matched with OR, or an object with `$and` or\n  `$not`.\n- **`location`** — `latitude`, `longitude` and `radius` in kilometres, all numeric.\n\n<details>\n\n<summary>Notes</summary>\n\n- Counts can be up to 2–3 hours old. They come from aggregation and caching, and the cache duration\n  adapts to system load.\n- Real-time results are not guaranteed, but freshness is sufficient for social proof and popularity.\n- Counts match the Netmera panel when the targeting is identical.\n- The count reflects users matching at query time. The delivery audience of a message can differ\n  slightly because of conditions applied at send time.\n- Only counts are returned; user lists are not exposed.\n- Attributes must be defined and active in the Netmera panel.\n- Tag, segment and profile attribute names are matched exactly, including letter case and spaces. An\n  unknown name returns HTTP 400, code 2009.\n- Profile attributes are referenced by name. The `and`/`or` keywords themselves are\n  case-insensitive.\n- Query several values in one request when possible.\n- Avoid polling the same entity repeatedly, and cache frequently displayed counts on your side.\n\n</details>\n","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["target"],"properties":{"target":{"type":"object","description":"Filtering rules used to select users whose profiles match the given\nconditions.\n","properties":{"tag":{"$ref":"#/components/schemas/TargetOperatorList","description":"Tag name, an array of tag names (OR), or an object with `$and`, `$or` or\n`$not`. An unknown tag returns HTTP 400 with code `2009`.\n"},"segment":{"$ref":"#/components/schemas/TargetOperatorList","description":"Segment name, an array of segment names (OR), or an object with `$and` or `$not`;\nthe `$or` object form is not supported, so use an array for OR. The segment must be\nactive and fully calculated.\n"},"location":{"$ref":"#/components/schemas/Location","description":"Geographical area: `latitude`, `longitude` and `radius` (kilometres), all\nrequired JSON numbers.\n"}},"additionalProperties":true}}}}}},"responses":{"200":{"description":"The distinct user count.","content":{"application/json":{"schema":{"type":"object","properties":{"count":{"type":"integer","description":"Total number of unique users matching the target."}}}}}},"400":{"description":"Missing target.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NetmeraError"}}}},"401":{"$ref":"#/components/responses/InvalidApiKey"},"403":{"$ref":"#/components/responses/IpNotAllowed"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://user.netmera.com/netmera-developer-guide/api-documentation/api-reference/segments-and-targeting/count-targeted-users.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
