Skip to content

REST API Reference

Complete reference for Pika Platform REST API endpoints.

Pika Platform has two separate APIs:

APIBase URLPurpose
Chat APIhttps://{domain}/api/chatUser-facing chat operations
Admin APIhttps://{domain}/api/chat-adminAdministrative operations

All API requests require authentication. The authentication method depends on your integration:

Authenticated via HTTP-only secure cookies set during login.

Cookie: session=xxx; Path=/; HttpOnly; Secure

Authenticated via JWT bearer token.

Authorization: Bearer <jwt_token>

All endpoints return JSON responses:

Success:

{
"success": true,
"data": { /* response data */ }
}

Error:

{
"success": false,
"error": "Error message description"
}

User-facing endpoints for chat operations.

Send a message to an agent.

Request:

{
userId: string;
sessionId?: string;
chatAppId: string;
agentId: string;
message: string;
features: ChatAppOverridableFeaturesForConverseFn;
files?: ChatMessageFile[];
timezone?: string;
invocationMode?: 'chat-app' | 'direct-agent-invoke' | 'chat-app-component';
source: 'user' | 'component-as-user' | 'component';
}

Response:

{
success: boolean;
response: string; // Agent's response
sessionId: string; // Session ID (created if not provided)
messageId: string; // Message ID
usage?: ChatMessageUsage; // Token usage and cost
}

Example:

Terminal window
curl -X POST https://your-domain.com/api/chat/converse \
-H "Content-Type: application/json" \
-H "Cookie: session=xxx" \
-d '{
"userId": "user-123",
"sessionId": "session-456",
"chatAppId": "support",
"agentId": "support-agent",
"message": "What is my order status?",
"features": {},
"source": "user"
}'

Get user's chat sessions.

Query Parameters:

ParameterTypeDescription
userIdstringUser ID (required)
chatAppIdstringFilter by chat app
limitnumberMax sessions to return (default: 20)

Response:

{
success: boolean;
sessions: ChatSession[];
}

Get messages for a session.

Query Parameters:

ParameterTypeDescription
userIdstringUser ID (required)
sessionIdstringSession ID (required)
limitnumberMax messages (default: 50)

Response:

{
success: boolean;
messages: ChatMessage[];
}

Update session title.

Request:

{
userId: string;
sessionId: string;
title?: string; // Explicit title
userQuestionAsked?: string; // For auto-generation
answerToQuestionFromAgent?: string; // For auto-generation
}

Response:

{
success: boolean;
title: string;
}

Get chat apps available to user.

Request:

{
userId: string;
chatAppId?: string; // Get specific app
chatAppsForHomePage?: boolean; // Filter for home page
customDataFieldPathToMatchUsersEntity?: string;
}

Response:

{
success: boolean;
chatApps: ChatApp[];
}

Get or create user.

Request:

{
userId: string;
}

Response:

{
success: boolean;
user: ChatUser;
}

Get user preferences.

Request:

{
userId: string;
}

Response:

{
success: boolean;
userId: string;
prefs: UserPrefs;
}

Update user preferences.

Request:

{
userId: string;
prefs: UserPrefs;
partial?: boolean; // Merge with existing
}

Response:

{
success: boolean;
prefs: UserPrefs;
}

Add session feedback.

Request:

{
feedback: ChatSessionFeedbackForCreate;
}

Response:

{
success: boolean;
feedback: ChatSessionFeedback;
}

Administrative endpoints requiring admin privileges.

Create or update agent.

Request:

{
agent: AgentDefinitionForCreate | AgentDefinitionForUpdate;
userId: string;
}

Response:

{
success: boolean;
agent: AgentDefinition;
}

Get agent definition.

Response:

{
success: boolean;
agent: AgentDefinition;
}

Delete agent.

Response:

{
success: boolean;
}

Search agents.

Request:

{
agentIds?: string[];
userId: string;
}

Response:

{
success: boolean;
agents: AgentDefinition[];
}

Create or update tool.

Request:

{
tool: ToolDefinitionForCreate | ToolDefinitionForUpdate;
userId: string;
}

Response:

{
success: boolean;
tool: ToolDefinition;
}

Get tool definition.

Response:

{
success: boolean;
tool: ToolDefinition;
}

Delete tool.

Response:

{
success: boolean;
}

Search tools.

Request:

{
toolIds: string[];
userId: string;
}

Response:

{
success: boolean;
tools: ToolDefinition[];
}

Create or update chat app.

Request:

{
chatApp: ChatAppForCreate | ChatAppForUpdate;
userId: string;
}

Response:

{
success: boolean;
chatApp: ChatApp;
}

Get chat app.

Response:

{
success: boolean;
chatApp: ChatApp;
}

Delete chat app.

Response:

{
success: boolean;
}

Search chat apps.

Response:

{
success: boolean;
chatApps: ChatApp[];
}

Search sessions with advanced filters.

Request:

{
command: 'sessionSearch';
search: SessionSearchRequest;
}

Response:

{
success: boolean;
sessions: ChatSession[];
total: number;
scrollId?: string;
pageSize: number;
}

Search Filters:

  • userId - Filter by user
  • chatAppId - Filter by chat app
  • customUserData - Filter by custom data fields
  • dateFilter - Date range filtering
  • flagged - Filter flagged sessions
  • insights - Filter by AI insights
  • feedbackInStatus - Filter by feedback status
  • sortBy - Custom sorting

Add or update feedback (admin).

Request:

{
command: 'addChatSessionFeedback' | 'updateChatSessionFeedback';
feedback: ChatSessionFeedbackForCreate | ChatSessionFeedbackForUpdate;
}

Response:

{
success: boolean;
feedback: ChatSessionFeedback;
}

Search users.

Request:

{
userIdPartial?: string;
limit?: number;
}

Response:

{
success: boolean;
users: ChatUserLite[];
}

See Tag Definitions API Reference for complete tag management endpoints.

Rate limits apply per user/API key:

Endpoint TypeLimitWindow
Chat endpoints100 requests1 minute
Admin endpoints1000 requests1 minute

Rate Limit Headers:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1642089600
HTTP StatusMeaning
200Success
400Bad Request - Invalid parameters
401Unauthorized - Authentication required
403Forbidden - Insufficient permissions
404Not Found - Resource doesn't exist
429Too Many Requests - Rate limit exceeded
500Internal Server Error

Error Response:

{
"success": false,
"error": "Detailed error message",
"code": "ERROR_CODE"
}
CodeDescription
INVALID_AGENT_IDAgent not found
INVALID_CHAT_APP_IDChat app not found
INVALID_SESSION_IDSession not found
INSUFFICIENT_PERMISSIONSUser lacks required permissions
RATE_LIMIT_EXCEEDEDToo many requests
INVALID_REQUESTRequest validation failed

Endpoints returning large datasets support pagination:

Request:

{
size?: number; // Page size (default: 20, max: 100)
scrollId?: string; // Continuation token from previous response
}

Response:

{
success: true,
data: [...],
scrollId?: string, // Token for next page
total: number, // Total results
pageSize: number // Current page size
}

Example Pagination:

// First request
let response = await fetch('/api/chat-admin/sessions/search', {
method: 'POST',
body: JSON.stringify({ size: 20 })
});
let data = await response.json();
// Next page
response = await fetch('/api/chat-admin/sessions/search', {
method: 'POST',
body: JSON.stringify({
scrollId: data.scrollId
})
});
import type { ConverseRequest, ConverseResponse } from 'pika-shared';
async function sendMessage(
message: string,
sessionId: string
): Promise<ConverseResponse> {
const request: ConverseRequest = {
userId: 'user-123',
sessionId,
chatAppId: 'support',
agentId: 'support-agent',
message,
features: {},
source: 'user'
};
const response = await fetch('/api/chat/converse', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(request),
credentials: 'include' // Include cookies
});
return response.json();
}
import requests
from typing import Dict, Any
def send_message(message: str, session_id: str) -> Dict[str, Any]:
payload = {
"userId": "user-123",
"sessionId": session_id,
"chatAppId": "support",
"agentId": "support-agent",
"message": message,
"features": {},
"source": "user"
}
response = requests.post(
"https://your-domain.com/api/chat/converse",
json=payload,
cookies={"session": "xxx"}
)
return response.json()
#!/bin/bash
# Send message
curl -X POST https://your-domain.com/api/chat/converse \
-H "Content-Type: application/json" \
-H "Cookie: session=xxx" \
-d '{
"userId": "user-123",
"sessionId": "session-456",
"chatAppId": "support",
"agentId": "support-agent",
"message": "Hello",
"features": {},
"source": "user"
}'
# Get sessions
curl -X GET "https://your-domain.com/api/chat/sessions?userId=user-123" \
-H "Cookie: session=xxx"
# Create agent (admin)
curl -X POST https://your-domain.com/api/chat-admin/agent \
-H "Content-Type: application/json" \
-H "Cookie: session=xxx" \
-d '{
"agent": {
"agentId": "new-agent",
"basePrompt": "You are helpful.",
"toolIds": [],
"createdBy": "admin",
"lastModifiedBy": "admin"
},
"userId": "admin"
}'

Pika can send webhooks for certain events:

EventTrigger
session.createdNew session started
session.completedSession ended
feedback.createdFeedback submitted
insight.generatedAI insight generated

Webhook Payload:

{
"event": "session.completed",
"timestamp": "2024-01-15T10:00:00Z",
"data": {
"sessionId": "session-123",
"userId": "user-456",
"chatAppId": "support"
}
}

Configure webhooks in your deployment configuration.

Track API changes in the Platform Changelog.

  • v1.2.0 - Added instructionAugmentation feature
  • v1.1.0 - Added session insights endpoints
  • v1.0.0 - Initial API release