Skip to main content
POST
/
api
/
upload_file
Upload File
curl --request POST \
  --url https://api.example.com/api/upload_file \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "room_id": "<string>"
}
'
{
  "200": {},
  "400": {},
  "401": {},
  "403": {},
  "500": {},
  "message": "<string>",
  "file_url": "<string>"
}

Overview

Uploads a file to a specified chat room. The file URL is automatically posted as a message in the room. Files are limited to 24MB.

Authentication

This endpoint requires authentication via an Authorization header containing a valid user token.

Request

Headers

Authorization
string
required
User authentication token

Body Parameters

This endpoint accepts multipart/form-data.
file
file
required
The file to upload. Maximum size: 24MB.
room_id
string
required
The ID of the chat room where the file will be posted

Response

message
string
Success message
file_url
string
The URL of the uploaded file

Status Codes

200
Success
File uploaded successfully
400
Bad Request
  • No file provided
  • No file name provided
  • No room ID provided
  • File size exceeds the 24MB limit
401
Unauthorized
  • Invalid token or token missing
  • Unauthorized access (invalid user)
403
Forbidden
You are not a member of this room
500
Internal Server Error
  • File upload failed
  • Internal server error

Example Request

cURL
curl -X POST https://api.example.com/api/upload_file \
  -H "Authorization: your-auth-token" \
  -F "file=@/path/to/your/file.pdf" \
  -F "room_id=room123"

Example Response

Success (200)
{
  "message": "File uploaded successfully",
  "file_url": "https://storage.example.com/uploads/file123.pdf"
}
Error - Missing Authorization (401)
{
  "error": "Invalid token or token missing"
}
Error - No File (400)
{
  "error": "No file provided"
}
Error - File Too Large (400)
{
  "error": "File size exceeds the 24MB limit"
}
Error - Not a Room Member (403)
{
  "error": "You are not a member of this room"
}
Error - Upload Failed (500)
{
  "error": "File upload failed: <error details>"
}

Notes

  • The uploaded file URL is automatically posted as a message in the specified room
  • Only room members can upload files to a room
  • The endpoint validates user membership before allowing the upload
  • Files must have a non-empty filename
  • Maximum file size is 24MB (24 * 1024 * 1024 bytes)

Build docs developers (and LLMs) love