get__conversation_{conversationId}_messages

⚠️ TEST ENVIRONMENT ONLY

This API endpoint is currently available only in the TEST environment. It is not yet available in production.

GET /conversation/{conversationId}/messages

Get Conversation Messages

Retrieve all messages from a conversation, including both user prompts and assistant responses. This endpoint returns the complete conversation history in chronological order.

Key Features:

  • Returns all messages from a conversation (user and assistant)

  • Messages are ordered chronologically (oldest first)

  • Includes message metadata such as token counts and model information

  • Supports conversation context retrieval for AI operations

  • Respects workspace and organization access controls

Message Types:

  • User messages - Prompts sent by users

  • Assistant messages - Responses generated by the AI

Important Notes:

  • Users must have access to the conversation's workspace

  • The conversation must exist and not be deleted

  • Organization administrators can view all conversations

  • Workspace administrators can view conversations in their workspaces

  • Regular users can only view their own conversations

  • Messages are retrieved from the external conversation API engine

Security:

  • Access is validated against workspace permissions

  • Only users with appropriate workspace access can retrieve messages

  • Message content is subject to policy enforcement and audit logging

Integration:

This endpoint integrates with external conversation API engines to retrieve conversation history. The system handles:

  • Fetching messages from the conversation store

  • Formatting and structuring message data

  • Including metadata and context information

  • Maintaining message order and timestamps

TypeScript Client Library

public getConversationMessages = async (conversationId: string): Promise<GetConversationMessagesResponse> => {
  return this.makeRequest<GetConversationMessagesResponse>(`conversation/${conversationId}/messages`, 'GET', null);
};

Code Samples

# You can also use wget
curl -X GET https://backend.flashback.tech/conversation/{conversationId}/messages \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer {access-token}'

Parameters

Name
In
Type
Required
Description

conversationId

path

string

true

Unique identifier of the conversation

Example responses

200 Response

{
  "success": true,
  "messages": [
    {
      "id": "msg-123",
      "conversationId": "conv-456",
      "role": "user",
      "content": "What is the best practice for securing API keys?",
      "tokenCount": 12,
      "model": null,
      "metadata": {},
      "createdAt": "2024-01-15T10:30:00.000Z"
    },
    {
      "id": "msg-124",
      "conversationId": "conv-456",
      "role": "assistant",
      "content": "The best practices for securing API keys include:\n\n1. Never commit API keys to version control\n2. Store keys in environment variables or secure vaults\n3. Rotate keys regularly\n4. Use least privilege access principles\n5. Monitor key usage for anomalies",
      "tokenCount": 87,
      "model": "gpt-4",
      "metadata": {
        "temperature": 0.7,
        "maxTokens": 1000
      },
      "createdAt": "2024-01-15T10:30:05.000Z"
    }
  ]
}

Responses

Status
Meaning
Description
Schema

200

Successfully retrieved messages

Inline

400

Invalid request

Inline

403

Insufficient permissions

Inline

404

Conversation not found

Inline

500

Failed to retrieve messages

Inline

Response Schema

Status Code 200

Name
Type
Required
Restrictions
Description

» success

boolean

false

none

Operation success status

» messages

[object]

false

none

Array of message objects

»» id

string

false

none

Unique identifier for the message

»» conversationId

string

false

none

Conversation ID this message belongs to

»» role

string

false

none

Message role ("user" or "assistant")

»» content

string

false

none

Message content text

»» tokenCount

integer

false

none

Number of tokens in the message

»» model

string

false

none

AI model used (for assistant messages)

»» metadata

object

false

none

Additional metadata (model parameters, etc.)

»» createdAt

string

false

none

ISO 8601 timestamp when message was created

Enumerated Values

Parameter
Value

»» role

user

»» role

assistant

Status Code 400

Name
Type
Required
Restrictions
Description

» success

boolean

false

none

none

» messages

array

false

none

none

» message

string

false

none

Error message

Status Code 403

Name
Type
Required
Restrictions
Description

» success

boolean

false

none

none

» messages

array

false

none

none

» message

string

false

none

Error message

Status Code 404

Name
Type
Required
Restrictions
Description

» success

boolean

false

none

none

» messages

array

false

none

none

» message

string

false

none

Error message

Status Code 500

Name
Type
Required
Restrictions
Description

» success

boolean

false

none

none

» messages

array

false

none

none

» message

string

false

none

Error message

To perform this operation, you must be authenticated by means of one of the following methods: BearerAuth

Last updated

Was this helpful?