Create Knowledgebase File

Upload a document to a specified knowledgebase.

POST
/
add
/
knowledgebase-file
import os
import requests
import json

# Replace with your API Key
os.environ["MEMOS_API_KEY"] = "YOUR_API_KEY"
os.environ["MEMOS_BASE_URL"] = "https://memos.memtensor.cn/api/openmem/v1"

data = {
  "knowledgebase_id": "basec32f88c6-9dd3-4061-82c8-f0fa0e85a284",# Replace with the Knowledge Base ID to upload documents to
  "file": [
    {"content": "https://cdn.memtensor.com.cn/file/出差报销额度说明.docx"}
  ]
}
headers = {
  "Content-Type": "application/json",
  "Authorization": f"Token {os.environ['MEMOS_API_KEY']}"
}
url = f"{os.environ['MEMOS_BASE_URL']}/add/knowledgebase-file"

res = requests.post(url=url, headers=headers, data=json.dumps(data))

print(f"result: {res.json()}")
{
  "code": 0,
  "data": {
    "id": "<string>",
    "name": "<string>",
    "sizeMB": 0,
    "status": "running"
  },
  "message": "<string>"
}

Authorizations

Authorization
string
header
required

Token API_key, available in API Console > API Keys

Body

application/json
knowledgebase_id
string
required

Target Knowledgebase ID

file
object[]
required

List of documents to upload

Show child attributes

Response

application/json

Successful Response

code
number
required

API status code. See Error Code for details.

data
object
Show child attributes
message
string
required

API response message