Skip to main content

Upload File

Step 1: get the file upload url

Request

POST https://rest.agentweave.ai/upload_file

Request Head

Authorization: AgentWeave User Access Token OR Api Key

Request Body

  • request_data (REQUIRED):
    • agent_id (REQUIRED)
    • file_name (REQUIRED)
    • file_size (REQUIRED)
    • file_type (REQUIRED): the MIME type of the file, e.g., application/pdf, image/png.
    • hash (REQUIRED): sha256 of file.
    • category (REQUIRED): "chat"
    • thread_id (OPTIONAL): a thread saves your previous messages, leave blank to start a new conversation, all subsequent messages related to this conversation must return the thread_id from the previous response as is to maintain context consistency.
    • owner_type (OPTIONAL): "user" OR "org", if not provided, it defaults to "user".
    • org_id (OPTIONAL): if owner_type="org", then org_id is required.
  • request_type (REQUIRED): "upload_file"

Example Request Body

{
"request_data": {
"agent_id": "open_chat_openai_c533c890-c1f0-444c-9bab-15cbae364a92",
"file_name": "name.png",
"file_type": "image/png",
"file_size": 910882,
"hash": "c46f6a4ad7869d4b5a84fa12511a762ff9dc68f63e0d596511c13270bd830545",
"category": "chat"
},
"request_type": "upload_file"
}

Response

  • data:
    • id: file id.
    • upload: the upload url, use this in step 2.
    • public: the url to directly get the file you uploaded.
    • thread_id: thread that this message belongs to, a thread saves your previous messages.
  • result:
    • code: 201000 means success, other indicates an error.
    • message: "Successfully." or error messages.

Step 2: upload file to the agent

Request

PUT upload

Request Head

Content-Type: the MIME type of the file.

Request Body

file