Attachment upload

Attachment upload integration

It is recommended to first read the previous chapter “File Upload”

File upload

Description

This API consolidates the previously separate file upload process, combining obtaining a Presigned URL, uploading the file to cloud storage, and uploading to Attachment into a single endpoint.

Endpoint Information

  • URL: https://api.maiagent.ai/api/v1/attachments-upload/

  • Method: POST

  • Content Type: multipart/form-data

Request Parameters

Parameter Name
Type
Required
Description

file

string(binary)

Yes

File to upload

Request Headers

Accept: application/json Authorization: Api-Key {your API key}

Request example

Send request using curl:

curl -X 'POST' \
  "https://api.maiagent.ai/api/v1/attachments-upload/" \
  -H 'accept: application/json' \
  -H 'Authorization: YOU_API_KEY' \
  -H 'Content-Type: multipart/form-data' \
  -H 'X-CSRFTOKEN: B85SZ7NcBcOKGl4xXU9cSfFhoLG7larxgCy2RYoz0mKSvcQydAboukuKCCKjGKV' \
  -F 'file=@32d91c61-79b3-40e1-b47d-e35d6d30861文件.xls;type=application/vnd.ms-excel'

Responses

Successful Response (Status Code: 201)

{
  "id": "c0f4b764-7cb8-4f1f-a1d4-80de93e6c3cc",
  "type": "other",
  "filename": "32d91c61-79b3-40e1-b47d-e35d6d30861文件.xls",
  "file": "https://api.maiagent.ai/media/chat/attachment/b82359c-cdd9-4cac-8ab1-c15be90e4d9b.xls"
}

Response field descriptions

Field Name
Type
Description

id

string

Unique identifier for the file

type

string

File type, for example "other"

filename

string

Original file name

file

string

Access URL for the file

Usage instructions

  1. Prepare the file to be uploaded

  2. Send a POST request using multipart/form-data format

  3. The request must include a valid API key

  4. After successful upload, the system will return the file ID and access URL

Notes

  • Please ensure you have appropriate permissions to use this API

  • File size may be limited; please refer to the plan purchased by your account's organization

  • Supported file types are as follows

Documents: .doc, .docx, .txt, .pdf, .md
Spreadsheets: .xls, .xlsx, .csv
Presentations: .ppt, .pptx
Other: .json, .jsonl

Last updated

Was this helpful?