> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rigaly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Preview a segment

> Returns the match count and a small sample for a segment filter — either a `preset_id` or custom filters (spend, visits, recency, time-of-day, birthday month…).



## OpenAPI

````yaml /openapi/v1.yaml post /api/v1/segments/preview
openapi: 3.1.0
info:
  title: Rigaly Business API
  version: '1.0'
  description: |
    Public API for businesses to manage their Rigaly loyalty programs: issue
    and redeem points, manage rewards, validate redemptions, and generate mass
    codes for physical products.

    All endpoints require an API key created in the Rigaly business dashboard
    (Tools → API Management), passed as `Authorization: Bearer rgly_sk_...`.
  contact:
    email: support@rigaly.com
servers:
  - url: https://api.rigaly.com
    description: Production
security:
  - apiKey: []
paths:
  /api/v1/segments/preview:
    post:
      tags:
        - Segments
      summary: Preview a segment
      description: >-
        Returns the match count and a small sample for a segment filter — either
        a `preset_id` or custom filters (spend, visits, recency, time-of-day,
        birthday month…).
      operationId: previewSegment
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                preset_id:
                  type: string
                  example: big_spenders
                filters:
                  type: object
                  description: Custom FilterSpec (alternative to preset_id)
      responses:
        '200':
          description: Count + sample
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuccessEnvelope'
components:
  schemas:
    SuccessEnvelope:
      type: object
      properties:
        success:
          type: boolean
          example: true
        message:
          type: string
        data:
          type: object
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: 'API key from the Rigaly dashboard: `Authorization: Bearer rgly_sk_...`'

````