InfiniSynapse Server API Reference

This document is the HTTP API reference for the InfiniSynapse Server, intended for external users/SDKs. With a single API Key (Bearer Token) you can directly invoke it to run multi-turn AI task conversations, manage data sources, manage RAG knowledge bases, upload and download files, and more—without relying on any frontend UI.

If you only need command-line integration, refer to the "InfiniSynapse CLI API Reference" first; this document targets developers who need to issue HTTP requests directly.

1. Getting Started

Basic Information

ItemValue
Base URL (Mainland China)https://app.infinisynapse.cn
Base URL (Overseas)https://app.infinisynapse.com
Global path prefixAll endpoints start with /api
AuthenticationHTTP header Authorization: Bearer <API Key>
Default content typeapplication/json (file uploads use multipart/form-data)

Users in Mainland China should use the .cn domain, and overseas users should use the .com domain; for on-premises deployments, replace it with your own service address. The examples below consistently use the .cn domain; for overseas environments, simply replace it with .com.

Authentication

All business endpoints require a Bearer Token in the request header:

Authorization: Bearer <your API Key>

The server parses the user identity (userId) from the Token's sub claim, and all resources (tasks, data sources, knowledge bases, files) are isolated per user. A few endpoints marked "public read-only" require no authentication.

Language

The optional request header x-lang controls the language of the prompt text returned by the server. Possible values: zh_CN (default), en, ar, ja, ko, ru.

x-lang: zh_CN

Unified Response Structure

Most endpoints return a unified envelope:

{
  "code": 200,
  "message": "success",
  "data": { }
}
  • code === 200 indicates success, and the business data is in data.
  • code of 1101 / 1105: the Token has expired or is invalid, and the API Key needs to be replaced.
  • Parameter validation failures return HTTP 422, with message being the first validation error message.
  • File download endpoints return a binary stream directly (application/octet-stream or application/zip) and do not use this envelope.

Pagination Conventions

List endpoints (inheriting from the common pagination parameters) support the following Query parameters:

ParameterTypeDefaultDescription
pagenumber1Page number (starting from 1)
pageSizenumber10Items per page (generally capped at 100; the data source list is capped at 10000)
fieldstring-Sort field, e.g. updated_at
orderstringdescSort direction asc / desc

The data structure of a paginated response:

{
  "items": [ ],
  "meta": {
    "itemCount": 10,
    "totalItems": 42,
    "itemsPerPage": 10,
    "totalPages": 5,
    "currentPage": 1
  }
}

Quick Start Example

curl -X GET "https://app.infinisynapse.cn/api/ai_database/list?page=1&pageSize=10&source=all" \
  -H "Authorization: Bearer <your API Key>" \
  -H "x-lang: zh_CN"

2. AI Conversation and Task Execution

AI conversation uses an asynchronous "SSE long connection + message delivery" model: first subscribe to the event stream to receive real-time pushes, then send instructions via the message endpoint.

2.1 Subscribe to the Event Stream (SSE)

  • GET /api/ai/events
  • Establishes a Server-Sent Events long connection; the server actively pushes message changes, state-ready signals, notifications, and more.

Query parameters

ParameterRequiredDescription
connIdNoA client-generated connection ID (e.g. a UUID); use one per tab/connection for multiple tabs/connections so the server can target pushes. If omitted, the server generates one automatically

Request headers: Authorization: Bearer <token> is required; Accept: text/event-stream is recommended.

Event types (each formatted as event: <event>\ndata: <JSON>\n\n)

eventdataDescription
message.add{ taskId, message }Append a message to the task
message.update{ taskId, message }Update an existing message
message.partial{ taskId, message }Streaming incremental update (overwrite or append at the same ts)
message.remove{ taskId, messageTs: number[] }Remove the specified messages
state.ready{ taskId }State is ready; it is recommended to subsequently call /api/ai_task/tasks for a full fetch
notification{ type, title, message, duration? }Global notification
heartbeat"ping"Keep-alive; can be ignored
curl -N "https://app.infinisynapse.cn/api/ai/events?connId=550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer <your API Key>" \
  -H "Accept: text/event-stream"

2.2 Send a Message

  • POST /api/ai/message
  • Dispatches to different logic based on the body's type. Replies are pushed in real time to the SSE channel; this endpoint itself only returns the execution result.

Common type values and fields

typeRequired fieldsOptional fieldsDescription
newTasktexttaskId, connId, images, filesCreate a new task (performs data source billing validation and idempotency)
askResponsetaskId, askResponsetext, images, filesReply to the Agent's question and continue the multi-turn conversation; askResponse is generally messageResponse
cancelTasktaskId-Cancel a running task
clearTask-taskIdClear a task; if taskId is omitted, clear all
optionsResponsetaskId, connId, text-Multiple-choice reply
togglePlanActModechatSettingstaskIdToggle planning/execution mode
autoApprovalSettingsautoApprovalSettings-Update the auto-approval configuration
rollbackToSnapshottaskId, snapshotTs-Roll back to the specified snapshot
rollbackAndSendMessagetaskId, snapshotTs, textimages, filesRoll back and send a new message
editFirstMessageAndResendtaskId, textimages, filesEdit the first message and re-execute

Response

  • Success is usually { "success": true };
  • newTask, rollback, editing the first message, etc. include { success: true, state, forceReplace? };
  • Failure may be { success: false, error } or { success: false, notification: { type, title, message } } (e.g. when billing validation fails).
# Create a new task
curl -X POST "https://app.infinisynapse.cn/api/ai/message" \
  -H "Authorization: Bearer <your API Key>" \
  -H "Content-Type: application/json" \
  -d '{"type":"newTask","text":"分析最近一个月的销售趋势","connId":"550e8400-..."}'

# Multi-turn follow-up
curl -X POST "https://app.infinisynapse.cn/api/ai/message" \
  -H "Authorization: Bearer <your API Key>" \
  -H "Content-Type: application/json" \
  -d '{"type":"askResponse","taskId":"task-001","askResponse":"messageResponse","text":"再按地区拆分"}'

2.3 Other Conversation Helper Endpoints

EndpointMethodDescription
/api/ai/state?taskId=GETGet the complete frontend state for the specified task (or globally): apiConfiguration, the current task, the message list, auto-approval, conversation mode, todo, etc.
/api/ai/settingsPOSTUpdate the API configuration, custom instructions, and auto-approval settings; when taskId is provided, also update that task's model
/api/ai/configurationGETGet the apiConfiguration saved by the current user
/api/ai/modelsGETRequest the OpenAI-compatible /models according to the current API configuration, returning an array of available model IDs
/api/ai/pingGETA lightweight heartbeat that returns { ok: true }, used to probe connection liveness

3. Task Management

Controller prefix: /api/ai_task.

3.1 Task Queries

EndpointMethodParametersDescription
/api/ai_task/listGETPagination parameters + task_name, category_name, category_id, is_in_rag, virtual_echart_category (all optional, fuzzy match)Get the task list with pagination
/api/ai_task/tasks?taskId=GETtaskId (required)Get the full task data (taskInfo + messages + isRunning)
/api/ai_task/getTaskInfo/:idGETPath idGet task metadata (without creating a running instance)
/api/ai_task/showTaskWithId/:idGETPath idGet task details
/api/ai_task/getUiMessageById?id=GETid (task ID)Get the task's UI message list (slimmed down)
/api/ai_task/messagePayload?taskId=&messageTs=GETtaskId, messageTsGet the full text of a single message (not slimmed down)
/api/ai_task/getTaskWorkspace/:idGETPath idGet the task working directory and file list { cwd, files }

3.2 Task Operations

Delete Tasks

  • POST /api/ai_task/deleteTaskWithId
{ "ids": ["task-001", "task-002"] }

Cancel a Task

  • POST /api/ai_task/cancelTask?taskId=task-001 (taskId as a Query parameter)

Rerun a SQL Task

  • POST /api/ai_task/rerunSqlTask
{ "id": "task-001", "chat_index": 0 }

Run Extracted SQL

  • POST /api/ai_task/runExtractSql
{
  "variables": { "startDate": "2024-01-01", "endDate": "2024-12-31" },
  "register_tables": "orders,users",
  "databases": "main_db",
  "sqls": "SELECT * FROM orders WHERE created_at BETWEEN :startDate AND :endDate"
}

3.3 Tasks and RAG

EndpointMethodBody/ParametersDescription
/api/ai_task/saveToRagPOST{ taskId, action }, where action is save/removeSave or remove a task to/from RAG
/api/ai_task/isSavedToRag?taskId=GETtaskIdReturns a boolean indicating whether the task has been saved to RAG

3.4 Task Categories

EndpointMethodBody/ParametersDescription
/api/ai_task/category/addPOST{ category_name }Add a category
/api/ai_task/category/updatePOST{ id, category_name }Update a category
/api/ai_task/category/deletePOST{ ids: [] }Delete categories
/api/ai_task/category/listGETPagination parameters + category_nameGet categories with pagination
/api/ai_task/category/getAllCategoriesGET-Get all categories
/api/ai_task/getCatetoryById/:idGETPath idCategory details
/api/ai_task/getCatetoryByTaskId/:idGETPath id (task ID)Get the categories associated with a task
/api/ai_task/updateCategoryByTaskIdPOST{ id, category_ids: [] }Update the categories associated with a task

3.5 Task Files

EndpointMethodBody/ParametersDescription
/api/ai_task/previewFilePOST{ taskId, fileName }Preview the file content, returning { content, fileType }
/api/ai_task/downloadZip?taskId=GETtaskIdDownload the entire task directory as a ZIP (returns a binary stream)

3.6 Task Sharing (public read-only, no authentication required)

EndpointMethodDescription
/api/ai_task/setSharePOST{ taskId, isPublic } sets the task as public/private (requires owner authentication)
/api/ai_task/shareStatus?taskId=GETQuery the sharing status (requires owner authentication)
/api/ai_task/publicTask?taskId=GETPublic read-only retrieval of task data
/api/ai_task/publicMessagePayload?taskId=&messageTs=GETPublic read-only retrieval of the full content of a single message
/api/ai_task/publicTaskFileTree/:taskIdGETPublic read-only retrieval of the file tree
/api/ai_task/publicPreviewFilePOSTPublic read-only file preview
/api/ai_task/publicDownloadTaskFile/:taskId?path=GETPublic read-only file download
/api/ai_task/publicDownloadZip?taskId=GETPublic read-only download of the task ZIP

4. Data Source Management

Controller prefix: /api/ai_database. Supported database types: mysql, postgres, sqlite, sqlserver, clickhouse, snowflake, doris, starrocks, gbase, kingbase, dm, supabase, deltalake, file (connection testing also supports mongodb, elasticsearch).

4.1 List Query

  • GET /api/ai_database/list

Query parameters: pagination parameters + the following optional items

ParameterDescription
nameDatabase name (fuzzy)
typeDatabase type
enabledWhether enabled: 1 / 0
sourceSource: local / remote / subscribed / all (default all)
subscribeSourceSubscription source: created / subscribed / all (default created)

4.2 Create, Update, Delete

EndpointMethodBodyDescription
/api/ai_database/addPOSTDatabaseAddDtoCreate a database connection
/api/ai_database/updatePOSTDatabaseEditDto (includes id)Update the database configuration
/api/ai_database/deletePOST{ ids: [] }Batch delete
/api/ai_database/enabledPOST{ ids: number[], enabled }Batch enable/disable

Example add request body:

{
  "name": "production_db",
  "type": "mysql",
  "config": "{\"mysql_host\":\"127.0.0.1\",\"mysql_port\":3306,\"mysql_username\":\"root\",\"mysql_password\":\"***\",\"mysql_database\":\"sales\"}",
  "enabled": 1,
  "description": "生产环境数据库",
  "nickname": "销售数据源"
}

Note: the database name must not start with remote_ or subscribe_.

4.3 Connection Testing and Queries

EndpointMethodBody/ParametersDescription
/api/ai_database/testConnectionPOST{ type, config }Test the connection, returning { success, message, latencyMs }
/api/ai_database/getDatabaseById/:idGETPath idQuery details by ID
/api/ai_database/getDatabaseByName/:nameGETPath nameQuery details by name

4.4 File and Knowledge Base Binding

EndpointMethodBody/ParametersDescription
/api/ai_database/upload/:databaseIdPOSTmultipart/form-data, field file (≤1GB)Upload a data file to the specified database
/api/ai_database/bindRagsPOST{ databaseId, ragIds: [] }Set the knowledge bases associated with the database
/api/ai_database/getBindRags/:databaseIdGETPath databaseIdGet the list of knowledge bases bound to the database

5. RAG Knowledge Base Management

Controller prefix: /api/ai_rag_sdk.

5.1 Queries

EndpointMethodParametersDescription
/api/ai_rag_sdkGETPagination parameters + keyword, enabled, source, subscribeSourceGet the knowledge base list with pagination
/api/ai_rag_sdk/allGET-Get all knowledge bases (no pagination)
/api/ai_rag_sdk/:idGETPath idKnowledge base details

5.2 Create, Update, Delete

EndpointMethodBodyDescription
/api/ai_rag_sdk/createPOSTRagSdkCreateDtoCreate a knowledge base
/api/ai_rag_sdk/update/:idPOSTRagSdkUpdateDtoUpdate a knowledge base
/api/ai_rag_sdk/deletePOST{ ids: [] }Batch delete
/api/ai_rag_sdk/enabledPOST{ ids: [], enabled }Batch enable/disable

Example create request body:

{
  "name": "sales_kb",
  "nickname": "销售知识库",
  "description": "销售相关文档",
  "ragDocFilterRelevance": "0.5",
  "requiredExts": [".pdf", ".docx", ".txt"],
  "docDir": "/path/to/docs",
  "enabled": 1,
  "database_ids": ["uuid-1", "uuid-2"]
}

5.3 Database Binding

EndpointMethodBody/ParametersDescription
/api/ai_rag_sdk/bindDatabasesPOST{ ragId, databaseIds: [] }Set the databases associated with the knowledge base
/api/ai_rag_sdk/getBindDatabases/:ragIdGETPath ragIdGet the list of databases bound to the knowledge base

5.4 File Operations (supports file / oss / s3)

EndpointMethodBodyDescription
/api/ai_rag_sdk/fileTreePOSTListDirectoryDtoList the directory file tree
/api/ai_rag_sdk/downloadPOSTDownloadFileDtoDownload a file (returns a binary stream)
/api/ai_rag_sdk/deleteRemoteFilePOSTDeleteRemoteFileDtoDelete a remote file (OSS/S3 only)

Example fileTree request body (remote OSS):

{
  "file_system": "oss",
  "directory": "/docs",
  "endpoint": "https://oss-cn-hangzhou.aliyuncs.com",
  "access_key_id": "***",
  "access_key_secret": "***",
  "filter": "both"
}

6. File Upload

The upload-related endpoints are registered under the root path (i.e. /api/...). Except for task uploads, ordinary uploads are organized by "directory".

EndpointMethodParametersDescription
/api/upload/:directoryPOSTmultipart/form-data field file (≤1GB)Upload a file to the specified directory, returning { filename }
/api/taskUpload/:taskIdPOSTfile + Query subdir, naming (original/hash)Upload a file to the task working directory, returning { filename, assetId, logicalPath, name, size }
/api/createDirectoryPOSTCreateDirectoryDtoCreate a directory
/api/deleteDirectoryDELETEDeleteDirectoryDtoDelete a directory
/api/directoriesGET-Get the directory list
/api/fileTree?keyword=GETkeyword (optional)Get the file tree structure
/api/taskFileTree/:taskIdGETPath taskIdGet the task working directory file tree
/api/uploadConfigGET-Get the upload limit configuration { maxFileSizeMB, maxFileSizeBytes, chat }
curl -X POST "https://app.infinisynapse.cn/api/upload/my-folder" \
  -H "Authorization: Bearer <your API Key>" \
  -F "file=@./data.csv"

7. File Storage and Download

Controller prefix: /api/storage.

EndpointMethodParametersDescription
/api/storage/deletePOST{ ids: [] }Delete files
/api/storage/download/:idGETPath id (format directory/filename, URL-encoded)Download a file (returns a binary stream)
/api/storage/downloadTaskFile/:taskId?path=GETPath taskId + Query path (file relative path, URL-encoded)Download a file from the task working directory
curl "https://app.infinisynapse.cn/api/storage/downloadTaskFile/task-001?path=data%2Fresult.csv" \
  -H "Authorization: Bearer <your API Key>" \
  -o result.csv

8. Error Handling

SymptomRecommended handling
code of 1101 / 1105The Token has expired or is invalid; replace the API Key and retry
HTTP 422Request parameter validation failed; message is the specific reason
HTTP 400Business validation failed (e.g. file too large, illegal naming, no file uploaded, etc.)
HTTP 404The resource/file does not exist or you do not have access
No SSE dataCheck the Authorization header and the network, and make sure you established the /api/ai/events connection before sending messages

9. Typical Call Flow

  1. Establish an SSE connection: GET /api/ai/events?connId=<uuid>.
  2. Prepare resources: GET /api/ai_database/list, GET /api/ai_rag_sdk, and enable as needed via POST /api/ai_database/enabled, POST /api/ai_rag_sdk/enabled.
  3. Create a new task: POST /api/ai/message (type=newTask), and receive real-time replies from SSE.
  4. Multi-turn follow-up: POST /api/ai/message (type=askResponse).
  5. View results: GET /api/ai_task/getTaskWorkspace/:id to list the artifacts, POST /api/ai_task/previewFile to preview, and GET /api/storage/downloadTaskFile/:taskId?path= to download.