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

# Sync preview of a personalized email for a single lead

> Blocking endpoint. Runs find_commonalities + generate_email inline against the provided lead + sender profile. Returns subject, body, commonality, and the prompt source used. Does not create a campaign, does not queue a job.



## OpenAPI

````yaml https://api.bavlio.com/openapi.json post /api/v1/personalize/preview
openapi: 3.1.0
info:
  title: Bavlio API
  description: >-
    Outreach automation API — lead enrichment, email campaigns, LinkedIn
    automation, and AI agent. Full docs at https://docs.bavlio.com.
  version: 1.0.0
servers: []
security: []
tags:
  - name: API Keys
    description: >-
      Create, list, and revoke API keys for programmatic access. JWT
      authentication required.
  - name: credits
    description: Credit balance, cost estimates, and transaction history.
  - name: campaigns
    description: Create, manage, launch, and monitor email campaigns.
  - name: campaign-personalization
    description: AI-powered email subject and body personalization for campaigns.
  - name: email-finder
    description: Find and verify email addresses for prospects.
  - name: email-verification
    description: Validate email addresses and prune invalid entries from datasets.
  - name: sender-profiles
    description: Manage sender identity profiles for outreach.
  - name: sender-profile-chat
    description: Interactive chat for building sender profiles.
  - name: templates
    description: Email template CRUD.
  - name: suppression
    description: Do-not-contact suppression list management.
  - name: datasets
    description: Lead dataset listing, download, and updates.
  - name: user-extractions
    description: Uploaded lead file management and processing.
  - name: enrichment-chat
    description: Interactive chat for data enrichment sessions.
  - name: enrichment-processing
    description: Batch lead enrichment processing.
  - name: File Upload (CSV/Excel)
    description: Upload and preview CSV/Excel lead files.
  - name: connected-accounts
    description: LinkedIn account connections via Unipile.
  - name: linkedin-content
    description: LinkedIn post creation, scheduling, and management.
  - name: linkedin-playground
    description: Direct LinkedIn actions (profile lookup, messaging, engagement).
  - name: bavimail-proxy
    description: BaviMail domain, alias, and email management.
  - name: agent
    description: Bavi AI agent chat with SSE streaming.
  - name: notifications
    description: Notification preferences and delivery.
  - name: referral
    description: Referral code management and stats.
  - name: feedback
    description: User feedback submission.
  - name: authentication
    description: JWT token verification and user info.
  - name: Google OAuth
    description: Google OAuth login flow and access tokens.
  - name: Google Sheets OAuth
    description: Google Sheets import and access management.
  - name: stripe
    description: Stripe checkout, billing portal, and subscription status. JWT only.
  - name: users
    description: User quota and usage information.
  - name: Health
    description: Health checks and system status.
  - name: Personalization
    description: Core lead personalization engine.
  - name: Session Management
    description: Enrichment session lifecycle.
  - name: Session Processing
    description: Session data processing.
  - name: webhooks
    description: Inbound webhook handlers (Stripe, BaviMail, Unipile).
paths:
  /api/v1/personalize/preview:
    post:
      tags:
        - Personalization
      summary: Sync preview of a personalized email for a single lead
      description: >-
        Blocking endpoint. Runs find_commonalities + generate_email inline
        against the provided lead + sender profile. Returns subject, body,
        commonality, and the prompt source used. Does not create a campaign,
        does not queue a job.
      operationId: personalize_preview_api_v1_personalize_preview_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PersonalizationPreviewRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PersonalizationPreviewResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    PersonalizationPreviewRequest:
      properties:
        lead_data:
          additionalProperties: true
          type: object
          title: Lead Data
          description: >-
            The lead fields to personalize against (company, role, linkedin_url,
            etc.)
        sender_profile_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Sender Profile Id
          description: >-
            ID of a saved sender profile. If omitted, sender_data must be
            provided.
        sender_data:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Sender Data
          description: >-
            Inline sender profile data. Ignored if sender_profile_id is
            provided.
        custom_prompt:
          anyOf:
            - type: string
            - type: 'null'
          title: Custom Prompt
          description: Optional prompt override. Must be 100-5000 characters if provided.
        research_context:
          anyOf:
            - type: string
              maxLength: 20000
            - type: 'null'
          title: Research Context
          description: >-
            Optional pre-fetched research context (overrides enrichment). Max
            20000 chars.
        dataset_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Dataset Id
          description: >-
            Optional dataset id for research cache persistence. Paired with
            row_index.
        row_index:
          anyOf:
            - type: integer
              minimum: 0
            - type: 'null'
          title: Row Index
          description: Row index within the dataset. Required when dataset_id is set.
        force_refresh_research:
          type: boolean
          title: Force Refresh Research
          description: >-
            Bypass the research cache and fetch fresh (e.g. user hit 'Refresh
            research').
          default: false
      type: object
      required:
        - lead_data
      title: PersonalizationPreviewRequest
      description: Input for the sync personalization preview.
    PersonalizationPreviewResponse:
      properties:
        subject:
          type: string
          title: Subject
        email_body:
          type: string
          title: Email Body
        commonality:
          $ref: '#/components/schemas/PersonalizationPreviewCommonality'
        prompt_source:
          type: string
          title: Prompt Source
          description: >-
            Which prompt was used: 'default', 'sender_profile_custom', or
            'custom_override'.
        model_used:
          type: string
          title: Model Used
        latency_ms:
          type: integer
          title: Latency Ms
        research_sources:
          items:
            $ref: '#/components/schemas/PersonalizationPreviewResearchSource'
          type: array
          title: Research Sources
          description: Which enrichment sources ran and whether they succeeded.
        research_chars:
          type: integer
          title: Research Chars
          default: 0
        research_latency_ms:
          type: integer
          title: Research Latency Ms
          default: 0
        research_from_cache:
          type: boolean
          title: Research From Cache
          default: false
        research_cached_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Research Cached At
        research_meta:
          additionalProperties: true
          type: object
          title: Research Meta
          description: >-
            Aggregate research metadata. Currently exposes
            `zero_research_reason` (one of the ZERO_RESEARCH_REASON_* enum
            values) when the joined research_chars was below the useful
            threshold. Used by ops sweep scripts to derive a per-cohort
            distribution of why some leads return empty research.
      type: object
      required:
        - subject
        - email_body
        - commonality
        - prompt_source
        - model_used
        - latency_ms
      title: PersonalizationPreviewResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    PersonalizationPreviewCommonality:
      properties:
        text:
          type: string
          title: Text
        confidence_score:
          type: number
          title: Confidence Score
        rarity_score:
          type: number
          title: Rarity Score
        relevance_score:
          type: number
          title: Relevance Score
        supporting_evidence:
          items:
            type: string
          type: array
          title: Supporting Evidence
      type: object
      required:
        - text
        - confidence_score
        - rarity_score
        - relevance_score
        - supporting_evidence
      title: PersonalizationPreviewCommonality
    PersonalizationPreviewResearchSource:
      properties:
        name:
          type: string
          title: Name
        status:
          type: string
          title: Status
        summary:
          type: string
          title: Summary
          default: ''
        meta:
          additionalProperties: true
          type: object
          title: Meta
        from_cache:
          type: boolean
          title: From Cache
          default: false
      type: object
      required:
        - name
        - status
      title: PersonalizationPreviewResearchSource
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````