> ## 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.

# Update an AI reply template

> Partially update a reply template: name, template_html, is_default (true moves the default onto it), rules (null clears them), from_address / to_address (null clears them).



## OpenAPI

````yaml patch /salesforce/ai-reply-templates/{id}
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/{id}:
    patch:
      summary: Update an AI reply template
      description: >-
        Partially update a reply template: name, template_html, is_default (true
        moves the default onto it), rules (null clears them), from_address /
        to_address (null clears them). Template HTML. Put {{content}} where the
        AI agent's reply goes (anything above is the greeting, anything below
        the signature); without it the template is appended below the reply.
        Variables: system objects {{contact.full_name}} / {{contact.first_name}}
        / {{contact.email}} / {{session.number}} / {{session.language}} /
        {{org.name}} (HTML-escaped) and any session attribute such as
        {{sf_case_Regards__c}} (inserted raw — Salesforce formula fields hold
        HTML fragments — then sanitized). {{#if sf_case_Language__c ==
        "de"}}…{{else}}…{{/if}} conditions are supported. Scripts, handlers and
        non-https images are stripped; {{content}} may appear at most once.
        Optional `from_address` / `to_address` set the From and To of the
        autopilot email per session: a literal address, a {{session attribute}}
        (e.g. {{sf_case_LatestPOSEmail__c}} as From, {{reservation_email}} as
        To) or an {{#if …}} branch. Each is used only when it resolves to an
        email address on that session; otherwise the From stays Salesforce's
        default sender and the To stays the Case contact. A literal that is not
        an email address is rejected with 400. Combine with `rules` to use
        different addresses for different sessions.
      operationId: updateSalesforceAiReplyTemplate
      parameters:
        - schema:
            type: string
            format: uuid
            pattern: >-
              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
          in: path
          name: id
          required: true
          description: Template ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateSalesforceAiReplyTemplateDto'
      responses:
        '200':
          description: Default Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SalesforceAiReplyTemplateDto'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
components:
  schemas:
    UpdateSalesforceAiReplyTemplateDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/UpdateSalesforceAiReplyTemplateDtoInput'
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 100
        template_html:
          type: string
          minLength: 1
          maxLength: 20000
        is_default:
          type: boolean
        rules:
          anyOf:
            - $ref: '#/components/schemas/SalesforceReplyTemplateRules'
            - type: 'null'
        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'
    SalesforceAiReplyTemplateDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/SalesforceAiReplyTemplateDto'
      type: object
      properties:
        id:
          type: string
          format: uuid
          pattern: >-
            ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
        name:
          type: string
        template_html:
          type: string
        is_default:
          type: boolean
        rules:
          anyOf:
            - $ref: '#/components/schemas/SalesforceReplyTemplateRules'
            - type: 'null'
        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.
          type:
            - string
            - '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.
          type:
            - string
            - 'null'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - id
        - name
        - template_html
        - is_default
        - rules
        - from_address
        - to_address
        - created_at
        - updated_at
      additionalProperties: false
    ErrorDto:
      type: object
      properties:
        statusCode:
          type: integer
        message:
          type: string
        error:
          type: string
    SalesforceReplyTemplateRules:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/SalesforceReplyTemplateRules'
      type: object
      properties:
        conditions:
          minItems: 1
          maxItems: 10
          type: array
          items:
            oneOf:
              - type: object
                properties:
                  type:
                    type: string
                    const: attribute
                  key:
                    type: string
                    minLength: 1
                    maxLength: 200
                  op:
                    type: string
                    enum:
                      - exists
                      - not_exists
                      - eq
                      - neq
                      - contains
                  value:
                    type: string
                    maxLength: 500
                required:
                  - type
                  - key
                  - op
                additionalProperties: false
              - type: object
                properties:
                  type:
                    type: string
                    const: tag
                  op:
                    type: string
                    enum:
                      - has
                      - not_has
                  value:
                    type: string
                    minLength: 1
                    maxLength: 200
                required:
                  - type
                  - op
                  - value
                additionalProperties: false
      required:
        - conditions
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

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