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

# Dapatkan Pesan

> Ambil semua pesan untuk percakapan tertentu.

<Callout type="warning">
  Catatan: Endpoint ini menggunakan header `merchant_id` dan `secret_key`, bukan `Business` dan `Secret`.
</Callout>

## Praktik Terbaik

1. **Validasi conversation\_id** - Pastikan formatnya benar sebelum membuat permintaan
2. **Tangani percakapan kosong** - Beberapa percakapan mungkin tidak memiliki pesan
3. **Parse metadata** - Field metadata adalah string JSON yang mungkin berisi informasi tambahan
4. **Periksa is\_note** - Filter catatan jika Anda hanya ingin pesan yang sebenarnya
5. **Cache respons** - Pertimbangkan untuk meng-cache riwayat pesan untuk mengurangi panggilan API

<Callout type="info">
  Pesan dikembalikan dalam urutan kronologis (terlama ke terbaru). Saat ini, endpoint ini mengembalikan semua pesan dalam percakapan. Paginasi akan ditambahkan di versi mendatang.
</Callout>


## OpenAPI

````yaml openapi.yaml get /v1/message/{conversation_id}
openapi: 3.0.3
info:
  title: CSKU AI API Publik
  description: >
    CSKU AI API Publik menyediakan endpoint untuk integrasi eksternal.


    API ini memungkinkan pengiriman pesan, pengelolaan percakapan, dan
    pengambilan riwayat pesan.


    ## Autentikasi


    Gunakan header Authorization dengan Secret Key Anda:


    ```

    Authorization: Bearer {secret_key}

    ```


    Dapatkan Secret Key Anda di https://app.csku.ai/settings/secret-key-settings


    ## Batas Rate


    - **100 permintaan per menit** untuk permintaan yang terautentikasi
  version: '1.3'
  contact:
    name: Dukungan CSKU AI
    email: support@csku.ai
    url: https://docs.csku.ai
servers:
  - url: https://api.csku.ai
    description: Server produksi
security:
  - BearerAuth: []
tags:
  - name: Pesan
    description: Endpoint pengelolaan pesan
  - name: Catatan
    description: Endpoint pengelolaan catatan
  - name: Percakapan
    description: Endpoint pengelolaan percakapan
paths:
  /v1/message/{conversation_id}:
    get:
      tags:
        - Pesan
      summary: Dapatkan pesan dalam percakapan
      description: Ambil semua pesan untuk percakapan tertentu.
      operationId: getMessages
      parameters:
        - name: conversation_id
          in: path
          required: true
          description: Pengidentifikasi percakapan yang unik
          schema:
            type: string
            example: conv_123456
      responses:
        '200':
          description: Respons berhasil dengan pesan
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessagesResponse'
              example:
                status: 1
                message: Sukses
                data:
                  - id: 1
                    message_id: msg_123
                    conversation_id: conv_123456
                    sender: user
                    message: Halo, saya butuh bantuan
                    message_type: text
                    mime_type: text/plain
                    sent_at: '2024-01-15 10:30:00'
                    metadata: '{}'
                    lock_by_human: 0
                    is_note: 0
        '401':
          description: Tidak terotorisasi
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Percakapan tidak ditemukan
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    MessagesResponse:
      type: object
      properties:
        status:
          type: integer
          example: 1
        message:
          type: string
          example: Sukses
        data:
          type: array
          items:
            $ref: '#/components/schemas/Message'
    ErrorResponse:
      type: object
      properties:
        status:
          type: integer
          description: Kode status (0 = error)
          example: 0
        rc:
          type: integer
          description: Kode respons/error
          example: 400
        error_msg:
          type: string
          description: Deskripsi pesan error
          example: Data tidak valid. Mohon periksa kembali parameter dan header
    Message:
      type: object
      properties:
        id:
          type: integer
          description: ID database pesan
          example: 1
        message_id:
          type: string
          description: Pengidentifikasi pesan yang unik
          example: msg_123
        conversation_id:
          type: string
          description: Pengidentifikasi percakapan
          example: conv_123
        sender:
          type: string
          description: Pengirim pesan (user, bot, agent)
          example: user
        message:
          type: string
          description: Konten pesan
          example: Halo, saya butuh bantuan
        message_type:
          type: string
          description: Jenis pesan (text, image, video, audio, document)
          example: text
        mime_type:
          type: string
          description: Tipe MIME pesan
          example: text/plain
        sent_at:
          type: string
          description: Waktu pengiriman pesan
          example: '2024-01-15 10:30:00'
        metadata:
          type: string
          description: Metadata tambahan (string JSON)
          example: '{}'
        lock_by_human:
          type: integer
          description: Apakah pesan dikunci oleh manusia (0 = tidak, 1 = ya)
          example: 0
        is_note:
          type: integer
          description: Apakah pesan adalah catatan (0 = tidak, 1 = ya)
          example: 0
        created_at:
          type: string
          description: Waktu pembuatan
          example: '2024-01-15 10:30:00'
        updated_at:
          type: string
          description: Waktu pembaruan terakhir
          example: '2024-01-15 10:30:00'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Secret Key dari dashboard
        (https://app.csku.ai/settings/secret-key-settings)

````