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

# Preview an AI reply template

> Preview an AI reply template — Render a template (saved or not) exactly as the AI agent would send it, against a real session of the organization: the session with…



## OpenAPI

````yaml post /salesforce/ai-reply-templates/preview
openapi: 3.1.0
info:
  title: OpenCX API
  description: >

    OpenCX is an AI-powered, all-in-one platform for customer support and
    outbound communications.


    Use this API to manage your OpenCX organization's AI agents, actions,
    conversations, contacts, and more.


    To get started, generate a new API key from the dashboard.


    ## Authentication

    All API endpoints require authentication using a Bearer token. You can
    generate an API key from your OpenCX dashboard.


    ## Rate Limiting

    API requests are rate limited to ensure fair usage. The current limits are:

    - 100 requests per minute for standard endpoints

    - 1000 requests per minute for streaming endpoints


    ## Error Handling

    The API uses standard HTTP status codes and returns detailed error messages
    in the response body.
  version: 1.0-beta
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
servers:
  - url: http://localhost:8080
    description: Development
  - url: https://api.open.cx
    description: Production
security:
  - bearerAuth: []
paths:
  /salesforce/ai-reply-templates/preview:
    post:
      summary: Preview an AI reply template
      description: >-
        Render a template (saved or not) exactly as the AI agent would send it,
        against a real session of the organization: the session with
        `session_number`, else the most recent Salesforce-linked session, else
        an empty context. Returns the rendered HTML and text, the session used,
        the variables that came out empty, and — when `from_address` /
        `to_address` are passed — the From and To the AI would use on that
        session (null = the default applies). Requires the write scope because
        it resolves real contact data.
      operationId: previewSalesforceAiReplyTemplate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PreviewSalesforceAiReplyTemplateDto'
      responses:
        '200':
          description: Default Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SalesforceAiReplyTemplatePreviewDto'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
components:
  schemas:
    PreviewSalesforceAiReplyTemplateDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/PreviewSalesforceAiReplyTemplateDtoInput'
      type: object
      properties:
        template_html:
          type: string
          minLength: 1
          maxLength: 20000
        session_number:
          type: integer
          exclusiveMinimum: 0
          maximum: 9007199254740991
        from_address:
          description: >-
            From address of the AI agent's autopilot Case email: a literal
            address, a {{session attribute}} such as
            {{sf_case_LatestPOSEmail__c}}, or an {{#if …}} branch, resolved per
            session. Used only when it resolves to an email address; otherwise
            Salesforce's default sender applies. Empty or null clears it.
          anyOf:
            - type: string
              maxLength: 500
            - type: 'null'
        to_address:
          description: >-
            To address of the AI agent's autopilot Case email: a literal
            address, a {{session attribute}} such as {{reservation_email}}, or
            an {{#if …}} branch, resolved per session. Used only when it
            resolves to an email address; otherwise the Case contact's address
            applies. Empty or null clears it.
          anyOf:
            - type: string
              maxLength: 500
            - type: 'null'
      required:
        - template_html
    SalesforceAiReplyTemplatePreviewDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/SalesforceAiReplyTemplatePreviewDto'
      type: object
      properties:
        html:
          type: string
        text:
          type: string
        session_number:
          type:
            - number
            - 'null'
        missing_variables:
          type: array
          items:
            type: string
        from_address:
          type:
            - string
            - 'null'
        to_address:
          type:
            - string
            - 'null'
      required:
        - html
        - text
        - session_number
        - missing_variables
        - from_address
        - to_address
      additionalProperties: false
    ErrorDto:
      type: object
      properties:
        statusCode:
          type: integer
        message:
          type: string
        error:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.