Skip to main content
POST
Add Message
Add user or assistant messages to track conversation flow. Supports both simple text messages and structured messages with multiple parts (text, context references, tool calls).

Request

Path Parameters

string
required
The session ID to add the message to

Headers

string
required
Your OpenViking API key for authentication
string
default:"application/json"
Must be application/json

Body Parameters

string
required
Message role: user or assistant
string
Simple text content (backward compatible mode). Mutually exclusive with parts.
array
Array of message parts for structured messages (text, context, tool). If both content and parts are provided, parts takes precedence.
string
required
Part type: text, context, or tool
For text parts:
string
required
Text content
For context parts:
string
required
Viking URI of the context (e.g., viking://resources/docs/auth/)
string
default:"memory"
Type of context: memory, resource, or skill
string
Brief description of the context
For tool parts:
string
Unique tool call identifier
string
Name of the tool being called
string
URI of the skill providing the tool
object
Input parameters for the tool
string
Tool execution output
string
default:"pending"
Execution status: pending, running, completed, or error

Response

string
Response status (ok or error)
object
Add message result
string
The session ID
number
Total number of messages in the session
number
Request processing time in seconds

Examples

Simple Text Message

Message with Context Reference

Message with Tool Call

Response Example

Message Roles

  • user - Messages from the end user
  • assistant - Messages from the AI assistant

Part Types

Text Part

Simple text content:

Context Part

Reference to a resource, memory, or skill:

Tool Part

Tool execution record:

Best Practices

Always Track Context Usage

Structure Messages Properly

Use parts for rich messages instead of mixing everything into text: