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

# Advanced Filter Preview

> Returns a preview of leads matching the given filter conditions.
Useful for campaign targeting previews.
Requires `leads:view` permission.




## OpenAPI

````yaml POST /api/leads/preview
openapi: 3.1.0
info:
  title: Naturalead Leads API
  version: 1.0.0
  description: |
    API for managing leads in the Naturalead platform. All endpoints require
    API key authentication and are scoped to the caller's account.
servers:
  - url: '{baseUrl}'
    description: API server
    variables:
      baseUrl:
        default: http://localhost:3001
security:
  - ApiKeyAuth: []
  - BearerAuth: []
tags:
  - name: Leads
    description: Lead CRUD, search, filtering, and bulk operations
paths:
  /api/leads/preview:
    post:
      tags:
        - Leads
      summary: Preview filtered leads
      description: |
        Returns a preview of leads matching the given filter conditions.
        Useful for campaign targeting previews.
        Requires `leads:view` permission.
      operationId: previewFilteredLeads
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                filters:
                  type: object
                  properties:
                    conditions:
                      type: array
                      items:
                        $ref: '#/components/schemas/FilterCondition'
                  required:
                    - conditions
                channel:
                  type: string
                skip:
                  type: integer
                limit:
                  type: integer
                  default: 5
              required:
                - filters
      responses:
        '200':
          description: Filtered leads preview
          content:
            application/json:
              schema:
                type: object
                properties:
                  leads:
                    type: array
                    items:
                      $ref: '#/components/schemas/Lead'
                  total:
                    type: integer
                required:
                  - leads
                  - total
        '400':
          $ref: '#/components/responses/BadRequest'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    FilterCondition:
      type: object
      properties:
        field:
          type: string
        operator:
          type: string
        value: {}
        conjunction:
          type: string
          enum:
            - and
            - or
      required:
        - field
        - operator
        - value
    Lead:
      type: object
      properties:
        id:
          type: integer
          description: Sequential, account-scoped identifier
        name:
          type: string
        phone:
          type: string
          description: Unique per account
        email:
          type: string
          default: ''
        status:
          $ref: '#/components/schemas/LeadStatus'
        accountId:
          type: string
        source:
          type: string
          default: api
        tags:
          type: array
          items:
            type: string
        assignedAgentId:
          type: string
          description: ObjectId reference to AgentConfig
        abTestId:
          type: string
          description: ObjectId reference to AbTest
        agentAssignedBy:
          type: string
          enum:
            - manual
            - ab_test
            - auto
          default: auto
        customFields:
          type: object
          additionalProperties:
            type: string
          description: Key-value string map of custom fields
        lastContactedAt:
          type: string
          format: date-time
        importBatchId:
          type: string
        externalId:
          type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      required:
        - id
        - name
        - phone
        - email
        - status
        - accountId
    LeadStatus:
      type: string
      enum:
        - new
        - contacted
        - qualified
        - disqualified
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
            required:
              - error
    InternalError:
      description: Internal server error
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
            required:
              - error
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key prefixed with `nl_live_` or `nl_test_`
    BearerAuth:
      type: http
      scheme: bearer
      description: Bearer token using an API key (format nl_live_* or nl_test_*)

````