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

# Opt-out Webhook Request Body

> This endpoint must be implemented on YOUR server (e.g., https://yourdomain.com/webhooks/on-optout). Treble will call this webhook when a user decides to opt out or exit the conversation. You must configure the URL of this webhook in the Treble admin panel.



## OpenAPI

````yaml open-api-files/treble-api-en.json POST /webhooks/on-optout
openapi: 3.0.1
info:
  title: Treble Poll API
  description: Documentation for the poll deployment endpoint in Treble
  version: 1.0.0
servers:
  - url: https://main.treble.ai
    description: Main Treble server
  - url: https://yourdomain.com
    description: >-
      Example server for implementing webhooks. This represents YOUR server
      where you must implement the endpoints that Treble will call.
security: []
tags:
  - name: Webhooks
    description: >-
      Endpoints that Treble will call on your server. These are not real
      endpoints that you can call, but a representation of the webhooks that
      Treble will invoke in your system.
paths:
  /webhooks/on-optout:
    post:
      tags:
        - Webhooks
      summary: Webhook - When a user opts out
      description: >-
        This endpoint must be implemented on YOUR server (e.g.,
        https://yourdomain.com/webhooks/on-optout). Treble will call this
        webhook when a user decides to opt out or exit the conversation. You
        must configure the URL of this webhook in the Treble admin panel.
      requestBody:
        description: Information of the opt-out event
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OptOutEvent'
            example:
              country_code: '+57'
              cellphone: '3176477608'
              session_id: 85b398ef5bcb20c355f3710c4509349784c907673c9118fb7a89c7a8
              conversation_id: 54263
              question:
                type: closed
                text: >-
                  Hi! Thanks for attending our webinar today. We would like to
                  have a feedback about our session and we would be very
                  grateful if you could help us with that. 
                answers:
                  - text: Sure
                  - text: No, thanks
                  - text: DEFAULT
              sent_at: '2021-10-22 00:15:39.044704'
              sent_text: >-
                Hi! Thanks for attending our webinar today. We would like to
                have a feedback about our session and we would be very grateful
                if you could help us with that. 

                1) Sure

                2) No, thanks

                3) DEFAULT
              user_session_keys: []
              classified_answer:
                text: No, thanks
              reason: OPTOUT
      responses:
        '200':
          description: Response to update or add information to the session
          content:
            application/json:
              schema:
                type: object
                description: >-
                  JSON object with the new information that will be replaced or
                  added to the session for future use. The service must respond
                  in less than 10 seconds.
      servers:
        - url: https://yourdomain.com
          description: Your server where you must implement this webhook
components:
  schemas:
    OptOutEvent:
      type: object
      required:
        - country_code
        - cellphone
        - session_id
        - conversation_id
        - question
        - sent_at
        - sent_text
        - classified_answer
        - reason
      description: >-
        Event that is triggered when a user decides to opt out or exit the
        conversation
      properties:
        country_code:
          type: string
          description: Country code of the user
        cellphone:
          type: string
          description: User's phone number without the country code
        session_id:
          type: string
          description: ID of the user's session
        conversation_id:
          type: integer
          description: ID of the conversation
        question:
          $ref: '#/components/schemas/ClosedQuestion'
        sent_at:
          type: string
          format: date-time
          description: Date and time when the question was sent
        sent_text:
          type: string
          description: Text sent to the user
        user_session_keys:
          type: array
          description: >-
            User session keys collected during the conversation or provided
            during the deployment
          items:
            $ref: '#/components/schemas/UserSessionKey'
        classified_answer:
          $ref: '#/components/schemas/Answer'
          description: Classified answer based on the user's response
        reason:
          type: string
          description: >-
            Reason for the user's exit, in this case 'OPTOUT' to indicate that
            the user decided to opt out
          enum:
            - OPTOUT
    ClosedQuestion:
      type: object
      required:
        - type
        - text
        - answers
      properties:
        type:
          type: string
          description: Type of question
          example: closed
        text:
          type: string
          description: Text of the question
        answers:
          type: array
          description: Possible answers for the closed question
          items:
            type: object
            properties:
              text:
                type: string
                description: Text of the answer
    UserSessionKey:
      type: object
      required:
        - key
        - value
      properties:
        key:
          type: string
          description: >-
            Name of the variable. Special values include 'deployment_squad' to
            select which phone number will perform the deployment in
            multi-channel companies.
        value:
          type: string
          description: >-
            Value of the variable. For 'deployment_squad', the value must be
            'DS_[CELLPHONE]'.
    Answer:
      type: object
      required:
        - text
      properties:
        text:
          type: string
          description: Text of the answer

````