AddFile

[POST] .../v1/chatmessage/addfile

Uploads a new file to the chat system folder for later use in a message. Use this method before ChatMessage/Add when a chat message needs an attached file. The endpoint accepts a JSON body with base64 data or multipart/form-data with a file part; chat_id, name, extension and either JSON data or multipart file content are required. The current request user must have file add permission, name is limited to 200 characters, extension to 10 characters, width and height must be positive together and duration_ms cannot be negative. Missing body, missing file data, invalid render metadata, file too large, denied permission, chat folder errors, file storage failures and database errors are returned as HTTP 200 ErrorResult business errors.

Request Parameters

Name Type Required Description
chat_id String Required Chat identifier (UUID).
data String Required File content in Base64.
duration_ms Int64 Optional Audio or video file duration in milliseconds.
extension String Required File extension.
height Int32 Optional Visual file height in pixels.
name String Required Display file name.
width Int32 Optional Visual file width in pixels.

Request Example

{
  "chat_id": "8cdd646d-dbd0-45c0-8f5b-d90a9b000001",
  "name": "invoice.pdf",
  "extension": "pdf",
  "data": "JVBERi0xLjQKJcTl8uXr"
}

Response Parameters

Name Type Description
ok Boolean Indicates whether the request completed successfully.
result ChatMessageAddFileResult Result object.

Response Example

{
  "ok": true,
  "result": {
    "file_id": 321
  }
}