# How many people match a rule or segment, and a few of them

`POST /crm/segments/preview` · Rivier · contacts

How many people match a rule or segment, and a few of them.

- Scope: contacts:read
- Graphql: Query.contactsSegmentPreview
- Sdk: contacts.segment.preview
- Cli: contacts segment preview

## Request body

`application/json`

```json
{
  "type": "object",
  "properties": {
    "rules": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "all": {
              "type": "array",
              "items": {},
              "minItems": 1,
              "maxItems": 50
            }
          },
          "required": [
            "all"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "any": {
              "type": "array",
              "items": {},
              "minItems": 1,
              "maxItems": 50
            }
          },
          "required": [
            "any"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "not": {}
          },
          "required": [
            "not"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "f": {
              "type": "string",
              "pattern": "^(email|name|phone|source|lifecycle|country|language|owner|company|tag|created_at|updated_at|last_activity_at|orders_count|orders_total|open_deals|segment|custom\\.[a-z][a-z0-9_]{0,39}|consent\\.(email|sms|whatsapp|phone)(\\.[a-z][a-z0-9_]{0,29})?|suppressed\\.(email|sms|whatsapp|phone))$"
            },
            "op": {
              "type": "string",
              "enum": [
                "eq",
                "ne",
                "contains",
                "starts",
                "in",
                "nin",
                "gt",
                "gte",
                "lt",
                "lte",
                "exists",
                "within_days",
                "older_than_days"
              ]
            },
            "v": {}
          },
          "required": [
            "f",
            "op"
          ],
          "additionalProperties": false
        }
      ]
    },
    "segmentId": {
      "type": "string",
      "format": "uuid"
    },
    "tag": {
      "type": "string",
      "maxLength": 40
    }
  },
  "additionalProperties": false
}
```

## Responses

- `200`: Success
- `400`: The request was malformed
- `401`: No valid credential
- `403`: The credential lacks the scope, origin or address
- `429`: Over the key's rate limit; see Retry-After

## Example

```sh
curl -X POST 'https://api.rivier.ai/crm/segments/preview' \
  -H 'Authorization: Bearer $KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "rules": {
    "all": []
  },
  "segmentId": "string",
  "tag": "string"
}'
```
