api.ts


Overview

The api.ts file serves as a centralized API endpoint configuration module within the application. It defines and exports a collection of RESTful API endpoint URLs, organized by functional domains such as user management, team operations, language model management, knowledge bases, document handling, chat, file management, system configuration, flows, agents, MCP servers, and search functionalities.

This file abstracts the API URL definitions, enabling consistent and maintainable usage of endpoints throughout the frontend or client-side codebase. It exports a default object containing string constants for fixed URLs and functions for dynamic URLs that require parameters (e.g., IDs or channel names).


Detailed Explanation

Constants


Default Export Object

The default export is a large plain object containing all API routes grouped logically by domain. Each key maps to either:


Domain Groups and Their Endpoints

User-related Endpoints

Key

Type

Description

Parameters

Example Usage

login

string

User login endpoint

None

api.login"/v1/user/login"

logout

string

User logout endpoint

None

api.logout"/v1/user/logout"

register

string

User registration endpoint

None

api.register"/v1/user/register"

setting

string

User settings endpoint

None

api.setting"/v1/user/setting"

user_info

string

Get user information

None

api.user_info"/v1/user/info"

tenant_info

string

Get tenant information associated with user

None

api.tenant_info"/v1/user/tenant_info"

set_tenant_info

string

Set tenant information

None

api.set_tenant_info"/v1/user/set_tenant_info"

login_channels

string

List login channels

None

api.login_channels"/v1/user/login/channels"

login_channel

(channel: string) => string

Login via specific channel

channel (string)

api.login_channel("google")"/v1/user/login/google"


Team-related Endpoints

Key

Type

Description

Parameters

Example Usage

addTenantUser

(tenantId: string) => string

Add a user to a tenant

tenantId (string)

api.addTenantUser("123")"/v1/tenant/123/user"

listTenantUser

(tenantId: string) => string

List users of a tenant

tenantId (string)

api.listTenantUser("123")"/v1/tenant/123/user/list"

deleteTenantUser

(tenantId: string, userId: string) => string

Remove a user from a tenant

tenantId, userId (string)

api.deleteTenantUser("123", "456")"/v1/tenant/123/user/456"

listTenant

string

List all tenants

None

api.listTenant"/v1/tenant/list"

agreeTenant

(tenantId: string) => string

Approve or agree to tenant invitation

tenantId (string)

api.agreeTenant("123")"/v1/tenant/agree/123"


LLM Model Endpoints

Key

Type

Description

factories_list

string

List LLM factories

llm_list

string

List available LLM models

my_llm

string

List LLM models owned by user

set_api_key

string

Set API key for LLM usage

add_llm

string

Add a new LLM model

delete_llm

string

Delete an existing LLM model

deleteFactory

string

Delete an LLM factory


Plugin Endpoints

Key

Type

Description

llm_tools

string

List or manage LLM tools


Knowledge Base Endpoints

Key

Type

Description

Parameters

Example Usage

kb_list

string

List knowledge bases

None

api.kb_list"/v1/kb/list"

create_kb

string

Create knowledge base

None

api.create_kb"/v1/kb/create"

update_kb

string

Update knowledge base

None

api.update_kb"/v1/kb/update"

rm_kb

string

Remove knowledge base

None

api.rm_kb"/v1/kb/rm"

get_kb_detail

string

Get knowledge base details

None

api.get_kb_detail"/v1/kb/detail"

getKnowledgeGraph

(knowledgeId: string) => string

Get knowledge graph for KB

knowledgeId (string)

api.getKnowledgeGraph("kb123")"/v1/kb/kb123/knowledge_graph"

getMeta

string

Get KB metadata

None

api.getMeta"/v1/kb/get_meta"


Tags Endpoints

Key

Type

Description

Parameters

Example Usage

listTag

(knowledgeId: string) => string

List tags for KB

knowledgeId (string)

api.listTag("kb123")"/v1/kb/kb123/tags"

listTagByKnowledgeIds

string

List tags across KBs

None

api.listTagByKnowledgeIds"/v1/kb/tags"

removeTag

(knowledgeId: string) => string

Remove tags from KB

knowledgeId (string)

api.removeTag("kb123")"/v1/kb/kb123/rm_tags"

renameTag

(knowledgeId: string) => string

Rename tag in KB

knowledgeId (string)

api.renameTag("kb123")"/v1/kb/kb123/rename_tag"


Chunk Endpoints

Includes endpoints for managing data chunks related to knowledge bases.

Key

Type

Description

chunk_list

string

List chunks

create_chunk

string

Create a chunk

set_chunk

string

Update a chunk

get_chunk

string

Get chunk details

switch_chunk

string

Switch chunk active status

rm_chunk

string

Remove chunk

retrieval_test

string

Test chunk retrieval mechanism

knowledge_graph

string

Chunk-related knowledge graph


Document Endpoints

Comprehensive document management including listing, status changing, upload, parsing, and thumbnails.

Key

Type

Description

get_document_list

string

List documents

document_change_status

string

Change document status

document_rm

string

Remove document

document_delete

string

Delete document

document_rename

string

Rename document

document_create

string

Create document

document_run

string

Execute document process

document_change_parser

string

Change document parser

document_thumbnails

string

Get document thumbnails

get_document_file

string

Get document file

document_upload

string

Upload document

web_crawl

string

Crawl web for documents

document_infos

string

Get document info

upload_and_parse

string

Upload and parse document

parse

string

Parse document

setMeta

string

Set document metadata

get_dataset_filter

string

Get dataset filter


Chat Endpoints

Endpoints to manage dialogs, conversations, messaging, and chat-related features.

Key

Type

Description

setDialog

string

Save dialog

getDialog

string

Get dialog

removeDialog

string

Remove dialog

listDialog

string

List dialogs

setConversation

string

Save conversation

getConversation

string

Get conversation

getConversationSSE

string

Get conversation via SSE (Server-Sent Events)

listConversation

string

List conversations

removeConversation

string

Remove conversation

completeConversation

string

Complete conversation

deleteMessage

string

Delete message

thumbup

string

Thumbs-up a message

tts

string

Text-to-speech functionality

ask

string

Ask a question

mindmap

string

Generate mindmap

getRelatedQuestions

string

Get related questions


Chat for External API

Key

Type

Description

createToken

string

Create API token for external chat

listToken

string

List API tokens

removeToken

string

Remove API token

getStats

string

Get API usage statistics

createExternalConversation

string

Create conversation externally

getExternalConversation

string

Get external conversation

completeExternalConversation

string

Complete external conversation

uploadAndParseExternal

string

Upload and parse doc externally


Next Chat Endpoints

Key

Type

Description

Parameters

Example Usage

listNextDialog

string

List next dialogs

None

api.listNextDialog"/v1/dialog/next"

fetchExternalChatInfo

(id: string) => string

Fetch external chatbot info

id (string)

api.fetchExternalChatInfo("bot123")"/api/v1/chatbots/bot123/info"


File Manager Endpoints

Key

Type

Description

listFile

string

List files

uploadFile

string

Upload file

removeFile

string

Remove file

renameFile

string

Rename file

getAllParentFolder

string

Get all parent folders

createFolder

string

Create folder

connectFileToKnowledge

string

Convert file to knowledge document

getFile

string

Get file

moveFile

string

Move file


System Endpoints

Key

Type

Description

getSystemVersion

string

Get system version

getSystemStatus

string

Get system status

getSystemTokenList

string

List system tokens

createSystemToken

string

Create system token

listSystemToken

string

List system tokens (duplicate key)

removeSystemToken

string

Remove system token

getSystemConfig

string

Get system configuration

setLangfuseConfig

string

Set Langfuse API key configuration


Flow (Canvas) Endpoints

Key

Type

Description

listTemplates

string

List canvas templates

listCanvas

string

List canvases

listCanvasTeam

string

List team canvases

getCanvas

string

Get canvas details

getCanvasSSE

string

Get canvas via SSE

removeCanvas

string

Remove canvas

setCanvas

string

Set or update canvas

settingCanvas

string

Canvas settings

getListVersion

string

Get list of canvas versions

getVersion

string

Get specific canvas version

resetCanvas

string

Reset canvas

runCanvas

string

Run canvas completion

testDbConnect

string

Test database connection

getInputElements

string

Get input elements of canvas

debug

string

Debug canvas

uploadCanvasFile

string

Upload file for canvas

trace

string

Trace canvas


Agent Endpoints

Key

Type

Description

Parameters

inputForm

string

Input form for canvas agent

None

fetchVersionList

(id: string) => string

Fetch version list for canvas

id

fetchVersion

(id: string) => string

Fetch a specific version

id

fetchCanvas

(id: string) => string

Fetch canvas by ID

id

fetchAgentAvatar

(id: string) => string

Fetch agent avatar via SSE

id

uploadAgentFile

(id?: string) => string

Upload file for agent

Optional id

fetchAgentLogs

(canvasId: string) => string

Fetch agent session logs

canvasId

fetchExternalAgentInputs

(canvasId: string) => string

Fetch external agent inputs

canvasId

prompt

string

Prompt for canvas agent

None


MCP Server Endpoints

Key

Type

Description

listMcpServer

string

List MCP servers

getMcpServer

string

Get MCP server details

createMcpServer

string

Create MCP server

updateMcpServer

string

Update MCP server

deleteMcpServer

string

Delete MCP server

importMcpServer

string

Import MCP server configuration

exportMcpServer

string

Export MCP server configuration

listMcpServerTools

string

List tools for MCP server

testMcpServerTool

string

Test MCP server tool

cacheMcpServerTool

string

Cache MCP server tools

testMcpServer

string

Test MCP server connectivity


Next-Search Endpoints

Key

Type

Description

createSearch

string

Create a new search

getSearchList

string

List searches

deleteSearch

string

Delete a search

getSearchDetail

string

Get search details

getSearchDetailShare

string

Get shared search details

updateSearchSetting

string

Update search settings

askShare

string

Ask question in shared search

mindmapShare

string

Mindmap in shared search

getRelatedQuestionsShare

string

Related questions in shared search

retrievalTestShare

string

Retrieval test in shared search


Implementation Details and Usage