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

# Fetch Thread

> Fetch a single thread of the chatbot



## OpenAPI

````yaml get /v0/chatbots/{chatbotId}/threads/{threadId}
openapi: 3.0.0
info:
  title: SiteGPT API Collection
  description: >-
    This collection contains the documentation of all the API endpoints.

    ## Getting started guide

    To start using the SiteGPT APIs, you need to 

    - You must use a valid API Key to send requests to the API endpoints. You
    can get your API key from SiteGPT's [billing
    dashboard](https://sitegpt.ai/billing). If you don't see it there, contact
    admin to generate one for you.

    - The API returns request responses in JSON format. When an API request
    returns an error, it is sent in the JSON response as an error key.
        
    ## Authentication

    SiteGPT uses API keys for authentication. You can generate a SiteGPT API key
    in the [billing dashboard](https://sitegpt.ai/billing).


    You must include an API key in each request to the Postman API with the
    Authorization request header.


    Header Name : Authorization


    Header Value : Bearer {{your-api-key}}


    ### Authentication error response

    If an API key is missing, malformed, or invalid, you will receive an HTTP
    401 Unauthorized response code.


    ## Need some help?

    In case you have any questions, feel free to contact us.
  license:
    name: SiteGPT Terms and Conditions
    url: https://sitegpt.ai/terms
  version: 1.0.0
  contact:
    name: Bhanu Teja P
    email: bhanu@sitegpt.ai
    url: mailto:bhanu@sitegpt.ai
servers:
  - url: https://sitegpt.ai/api
security:
  - bearerAuth: []
tags:
  - name: Chatbot
    x-displayName: Chatbots
    description: >-
      APIs to manage different chatbots. APIs include `Fetching All Chatbots`,
      `Creating New Chatbot`, Fetching One Chatbot`, `Updating Chatbot
      Appearance` and `Deleting Chatbot`.
    x-mint:
      icon: message-bot
  - name: Chatbot Appearance
    x-displayName: Appearance
    description: APIs to update appearance of the chatbot.
    x-mint:
      icon: palette
  - name: Chatbot Custom Content
    x-displayName: Custom Content
    description: APIs to modify custom content of the chatbot.
    x-mint:
      icon: file-pen
  - name: Chatbot Follow Up Prompts
    x-displayName: Follow-up Prompts
    description: >-
      APIs to manage `Follow up Prompts` of a particular chatbot. APIs include
      `Fetching All Follow up Prompts`, `Adding New Follow up Prompt`, `Fetching
      One Follow up Prompt`, `Updating Follow up Prompt` and `Deleting Follow up
      Prompt`.
    x-mint:
      icon: message-arrow-up
  - name: Chatbot Icons
    x-displayName: Icons
    description: APIs to manage (add/update/delete) icons related to a particular chatbot.
    x-mint:
      icon: icons
  - name: Chatbot Links
    x-displayName: Content & Training
    description: >-
      APIs to fetch internal links of any url and to add certain links to a
      particular chatbot.
    x-mint:
      icon: book-open
  - name: Chatbot Messages
    x-displayName: Messages
    description: >-
      APIs to send a message to a particular thread or start a new conversation
      with in a particular chatbot.
    x-mint:
      icon: messages
  - name: Chatbot Personas
    x-displayName: Personas
    description: APIs to manage personas of the chatbot.
    x-mint:
      icon: user-tie
  - name: Chatbot Prompts
    x-displayName: Instructions
    description: APIs to manage prompts of the chatbot.
    x-mint:
      icon: message-text
  - name: Chatbot Conversation Starters
    x-displayName: Conversation Starters
    description: >-
      APIs to manage `Conversation Starters` of a particular chatbot. APIs
      include `Fetching All Conversation Starters`, `Adding New Conversation
      Starter`, `Fetching One Conversation Starter`, `Updating Conversation
      Starter` and `Deleting Conversation Starter`.
    x-mint:
      icon: bolt
  - name: Chatbot Settings
    x-displayName: Settings
    description: >-
      APIs to update different settings of the chatbot. APIs include `General
      Settings`, `User Data Settings`, `Chat Mode Settings`, `Localization
      Settings` and `Advanced Settings`.
    x-mint:
      icon: gear
  - name: Chatbot Threads
    x-displayName: Threads
    description: >-
      APIs to manage threads related to a particular chatbot. APIs include
      `Fetching All Threads`, `Fetching One Thread` and `Update Thread`.
    x-mint:
      icon: message-lines
  - name: Whitelabel
    x-displayName: Whitelabel (Deprecated)
    description: >-
      APIs to manage whitelabel users. APIs include `Create Whitelabel User` and
      `Update Whitelabel User Quota`.
    x-mint:
      icon: tag
paths:
  /v0/chatbots/{chatbotId}/threads/{threadId}:
    parameters:
      - name: chatbotId
        description: Id of the chatbot
        in: path
        schema:
          type: string
        required: true
      - schema:
          type: string
        name: threadId
        in: path
        required: true
        description: Id of the chatbot thread
    get:
      tags:
        - Chatbot Threads
      summary: Fetch Thread
      description: Fetch a single thread of the chatbot
      operationId: fetch-chatbot-thread
      parameters:
        - name: chatbotId
          description: Id of the chatbot
          in: path
          schema:
            type: string
          required: true
        - schema:
            type: string
          name: threadId
          in: path
          required: true
          description: Id of the chatbot thread
        - schema:
            type: boolean
          in: query
          name: skipMessages
          description: Parameter to identify if messages needs to be returned or not
        - schema:
            type: boolean
          in: query
          name: includeChatUser
          description: >-
            Parameter to identify if chat user details needs to be returned or
            not
      responses:
        '200':
          description: OK
          headers:
            Content-Type:
              schema:
                type: string
              description: application/json
          content:
            application/json:
              schema:
                type: object
                description: Success Response
                properties:
                  success:
                    type: boolean
                    description: >-
                      Indicates whether this is success response or error
                      response
                  message:
                    type: string
                    description: Overall message regarding the operation performed
                  data:
                    type: object
                    description: Data returned from the server
                    properties:
                      thread:
                        $ref: '#/components/schemas/Thread'
              examples:
                Success:
                  value:
                    success: true
                    message: Fetched the thread successfully
                    data:
                      thread:
                        threadId: 06b3b43c-5651-49a2-b618-d7f24667c1b6
                        mode: AI
                        messages:
                          - messageId: '365062948587045457'
                            question:
                              text: Hello, what is this?
                              timestamp: '2023-05-18T11:40:07.857030Z'
                            answer:
                              text: >-
                                Hello! I am an AI assistant designed to provide
                                information about the website's content. If you
                                have any specific questions, feel free to ask
                                and I will do my best to provide accurate
                                answers.
                              timestamp: '2023-05-18T11:40:07.857030Z'
                            reaction: NEUTRAL
                            sources: []
                            messageType: NORMAL_MESSAGE
                            systemMessageType: CONVERSATION_ESCALATED
                            iconUrl: null
                            prompts: []
                            gptModel: gpt-3.5-turbo
                          - messageId: '365064286366597712'
                            question:
                              text: Hi
                              timestamp: '2023-05-18T12:01:23.667033Z'
                            answer: null
                            reaction: NEUTRAL
                            sources: []
                            messageType: USER_MESSAGE
                            systemMessageType: CONVERSATION_ESCALATED
                            iconUrl: null
                            prompts: []
                            gptModel: gpt-3.5-turbo
                          - messageId: '365064310572974672'
                            question: null
                            answer:
                              text: YO
                              timestamp: '2023-05-18T12:01:46.751791Z'
                            reaction: NEUTRAL
                            sources: []
                            messageType: AGENT_MESSAGE
                            systemMessageType: CONVERSATION_ESCALATED
                            iconUrl: null
                            prompts: []
                            gptModel: gpt-3.5-turbo
                        startedAt: '2023-05-18T11:39:57.349750Z'
                        updatedAt: '2023-05-18T11:39:57.349750Z'
                        webhookUrl: https://hooks.zapier.com/hooks/catch/15695697/3hqs23e
                        totalMessagesRead: 47
                        chatUserId: null
                        chatbotId: '365062873485935184'
                        chatUser: null
        '400':
          description: Bad Request
          headers:
            Content-Type:
              schema:
                type: string
              description: application/json
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                Validation Error:
                  value:
                    success: false
                    message: Failed to fetch the chatbot thread
                    data: null
                    error:
                      code: THREAD_ID_REQUIRED
                      message: threadId field is required
                      details: null
        '401':
          description: Unauthorized
          headers:
            Content-Type:
              schema:
                type: string
              description: application/json
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                Authentication Error:
                  value:
                    success: false
                    message: Failed to fetch the chatbot thread
                    error:
                      code: API_KEY_NOT_VALID
                      message: Authorization header does not contain valid API key
                      details: null
        '403':
          description: Forbidden
          headers:
            Content-Type:
              schema:
                type: string
              description: application/json
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                Forbidden Error:
                  value:
                    success: false
                    message: Failed to fetch the chatbot thread
                    data: null
                    error:
                      code: FETCH_CHATBOT_THREAD_FORBIDDEN
                      message: You are not authorized to fetch this chatbot thread
                      details: null
        '404':
          description: Not Found
          headers:
            Content-Type:
              schema:
                type: string
              description: application/json
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                Not Found Error:
                  value:
                    success: false
                    message: Failed to fetch the chatbot thread
                    data: null
                    error:
                      code: CHATBOT_THREAD_NOT_FOUND
                      message: Chatbot thread does not exist for threadId=1234567890
                      details: null
        '405':
          description: Method Not Allowed
          headers:
            Content-Type:
              schema:
                type: string
              description: application/json
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                Method Not Allowed Error:
                  value:
                    success: false
                    message: Failed to fetch the chatbot thread
                    data: null
                    error:
                      code: REQUEST_METHOD_NOT_ALLOWED
                      message: PATCH request method is not allowed
                      details: null
        '500':
          description: Internal Server Error
          headers:
            Content-Type:
              schema:
                type: string
              description: application/json
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                Server Error:
                  value:
                    success: false
                    message: Failed to fetch the chatbot thread
                    data: null
                    error:
                      code: FETCH_CHATBOT_THREAD_FAILED
                      message: Some technical error has occurred !!
                      details: null
components:
  schemas:
    Thread:
      title: Thread
      type: object
      description: Chatbot Thread
      properties:
        threadId:
          type: string
          description: Id of the chatbot thread
        chatbotId:
          type: string
          description: Id of the chatbot
        chatUserId:
          type: string
          description: Id of the user chatting in the thread
          nullable: true
        mode:
          enum:
            - AI
            - AGENT
          description: Mode of the thread
        startedAt:
          type: string
          format: date-time
          description: Timestamp indicating when the thread has been started
        updatedAt:
          type: string
          format: date-time
          description: Timestamp indicating when the thread has been last updated
        endedAt:
          type: string
          format: date-time
          description: Timestamp indicating when the thread has been ended
        escalated:
          type: boolean
          description: Indicates whether conversation has been escalated or not
        webhookUrl:
          type: string
          description: All messages are sent to this webhook url
          nullable: true
        webhookToken:
          type: string
          description: >-
            The token which is sent in header in the calls made to the above
            webhook url for all messages
          nullable: true
        messages:
          type: array
          description: Messages of the thread
          items:
            $ref: '#/components/schemas/ThreadMessage'
        totalMessagesRead:
          type: integer
          description: Number of messages that are read in this thread
        chatUser:
          $ref: '#/components/schemas/ChatUser'
    ErrorResponse:
      type: object
      description: Error Response
      properties:
        success:
          type: boolean
          description: Indicates that this is error response
        message:
          type: string
          description: Overall error message regarding the operation performed
        data:
          type: object
          description: Data returned from the API. This will be `null` for errors
          nullable: true
        error:
          type: object
          description: Object with the error details
          properties:
            code:
              type: string
              description: Based on this error code, you can identify what is the error
            message:
              type: string
              description: The message indicating the reason for the error
            details:
              type: array
              description: More details on the error. Applicable only for Validation errors
              nullable: true
              items:
                type: object
                properties:
                  path:
                    type: array
                    description: >-
                      Specifies the path in request body where error occurred.
                      If the error field is nexted, then this array length will
                      be more than 1.
                    items:
                      oneOf:
                        - type: string
                          description: Specifies the name of the field
                        - type: integer
                          description: Specifies the position in an array
                  message:
                    type: string
                    description: Reason for the error of the path mentioned before
    ThreadMessage:
      title: Thread-Message
      type: object
      description: Message of a thread
      properties:
        messageId:
          type: string
          description: Id of the message
        messageType:
          $ref: '#/components/schemas/MessageType'
        systemMessageType:
          $ref: '#/components/schemas/SystemMessageType'
        question:
          $ref: '#/components/schemas/ChatQuestionAnswer'
        answer:
          $ref: '#/components/schemas/ChatQuestionAnswer'
        reaction:
          $ref: '#/components/schemas/MessageReaction'
        sources:
          type: array
          description: Sources used to answer the question
          items:
            type: string
        escalated:
          type: boolean
          description: Indicates whether this message is escalated or not
        iconUrl:
          type: string
          description: Url of the icon used in this message
          nullable: true
        prompts:
          type: array
          description: Quick prompts that have been configured by chatbot owner
          nullable: true
          items:
            $ref: '#/components/schemas/QuickPrompt'
        gptModel:
          type: string
          description: GPT Model used to answer the question
    ChatUser:
      title: Chat-User
      type: object
      description: Chat User
      nullable: true
      properties:
        id:
          type: string
          description: Id of the user
        name:
          type: string
          description: Name of the user
        email:
          type: string
          format: email
          description: Email Id of the user
        phone:
          type: string
          description: Phone Number of the user
        verified:
          type: boolean
          description: Indicates whether the user is verified or not
        createdAt:
          type: string
          format: date-time
          description: Timestamp indicating when the user is created
        updatedAt:
          type: string
          format: date-time
          description: Timestamp indicating when the user is last updated
    MessageType:
      title: Message-Type
      description: Type of the message in the thread
      enum:
        - NORMAL_MESSAGE
        - USER_MESSAGE
        - AGENT_MESSAGE
        - SYSTEM_MESSAGE
    SystemMessageType:
      title: System-Message-Type
      description: Type of the message if type of the message is SYSTEM_MESSAGE
      enum:
        - CONVERSATION_ESCALATED
        - EXCEEDED_USAGE_LIMITS
        - EMAIL_VERIFIED
        - ENTERED_WRONG_OTP
        - PROVIDED_EMAIL
        - PERSONA_SELECTED
        - PROBLEMS_WITH_UPSTREAM_PROVIDER
        - COLLECT_LEAD
    ChatQuestionAnswer:
      title: Chat-Question-Answer
      type: object
      description: Model for question/answer in the chat
      nullable: true
      properties:
        text:
          type: string
          description: Text containing either question or the answer
        timestamp:
          type: string
          format: date-time
          description: Timestamp of the question asked or answer replied
    MessageReaction:
      title: Message-Reaction
      description: User's reaction to the message
      enum:
        - POSITIVE
        - NEGATIVE
        - NEUTRAL
    QuickPrompt:
      type: object
      description: Chatbot Conversation Starter
      properties:
        id:
          type: string
          description: Id of the conversation-starter
        title:
          type: string
          description: >-
            Title of the conversation-starter. This is the text that is shown as
            button in the chatbot.
        link:
          type: string
          description: >-
            Link of the conversation starter. If this link is not null, then
            when you click on the conversation starter in the chatbot, this link
            will be opened instead of sending a message to the chatbot.
          nullable: true
        description:
          type: string
          description: >-
            Description of the conversation-starter. This is the message that
            will be sent to the chatbot when you click on the
            conversation-starter inside the chatbot.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````