附件與檔案
建立新附件
POST /api/attachments/
請求內容
{
"type": {},
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf"
}
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X POST "https://api.maiagent.ai/api/attachments/" \
-H "Authorization: Api-Key YOUR_API_KEY" \
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。
const axios = require('axios');
// 請求內容 (payload):
const data = {};
// 設定請求標頭
const config = {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY',
'Content-Type': 'application/json'
}
};
axios.post("https://api.maiagent.ai/api/attachments/", data, config)
.then(response => {
console.log('成功取得回應,以下是數據:');
console.log(response.data);
})
.catch(error => {
console.error('請求發生錯誤,請檢查請求內容與 API Key:');
console.error(error.response?.data || error.message);
});
import requests
import json
url = "https://api.maiagent.ai/api/attachments/"
headers = {
"Authorization": "Api-Key YOUR_API_KEY",
"Content-Type": "application/json"
}
# 請求內容 (payload)
data = {}
response = requests.post(url, json=data, headers=headers)
try:
print("成功取得回應,以下是返回數據:")
print(response.json())
except Exception as e:
print("請求出現錯誤,請檢查輸入參數與 API Key:", e)
<?php
require 'vendor/autoload.php';
$client = new GuzzleHttpClient();
try {
$response = $client->post("https://api.maiagent.ai/api/attachments/", [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY',
'Content-Type' => 'application/json'
],
// 請求內容 (payload) 已包含在請求中
'json' => {}
]);
$data = json_decode($response->getBody(), true);
echo "成功取得回應:
";
print_r($data);
} catch (Exception $e) {
echo '發生錯誤, 請檢查請求細節及 API Key: ' . $e->getMessage();
}
?>
回應內容
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": {},
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf"
}
取得檔案上傳用的預簽署 URL (建立/取得)
POST /api/v1/upload-presigned-url/
請求內容
{
"modelName": "example_string",
"fieldName": "example_string",
"filename": "example.pdf",
"fileSize": 0
}
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/upload-presigned-url/" \
-H "Authorization: Api-Key YOUR_API_KEY" \
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。
const axios = require('axios');
// 請求內容 (payload):
const data = {};
// 設定請求標頭
const config = {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY',
'Content-Type': 'application/json'
}
};
axios.post("https://api.maiagent.ai/api/v1/upload-presigned-url/", data, config)
.then(response => {
console.log('成功取得回應,以下是數據:');
console.log(response.data);
})
.catch(error => {
console.error('請求發生錯誤,請檢查請求內容與 API Key:');
console.error(error.response?.data || error.message);
});
import requests
import json
url = "https://api.maiagent.ai/api/v1/upload-presigned-url/"
headers = {
"Authorization": "Api-Key YOUR_API_KEY",
"Content-Type": "application/json"
}
# 請求內容 (payload)
data = {}
response = requests.post(url, json=data, headers=headers)
try:
print("成功取得回應,以下是返回數據:")
print(response.json())
except Exception as e:
print("請求出現錯誤,請檢查輸入參數與 API Key:", e)
<?php
require 'vendor/autoload.php';
$client = new GuzzleHttpClient();
try {
$response = $client->post("https://api.maiagent.ai/api/v1/upload-presigned-url/", [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY',
'Content-Type' => 'application/json'
],
// 請求內容 (payload) 已包含在請求中
'json' => {}
]);
$data = json_decode($response->getBody(), true);
echo "成功取得回應:
";
print_r($data);
} catch (Exception $e) {
echo '發生錯誤, 請檢查請求細節及 API Key: ' . $e->getMessage();
}
?>
回應內容
{
"modelName": "example_string",
"fieldName": "example_string",
"filename": "example.pdf",
"fileSize": 0
}
取得附件列表
GET /api/attachments/
參數
參數名稱
必填
類型
說明
page
否
integer
A page number within the paginated result set.
pageSize
否
integer
Number of results to return per page.
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X GET "https://api.maiagent.ai/api/attachments/" \
-H "Authorization: Api-Key YOUR_API_KEY" \
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。
const axios = require('axios');
// 設定請求標頭 (請替換 YOUR_API_KEY)
const config = {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY'
}
};
axios.get("https://api.maiagent.ai/api/attachments/", config)
.then(response => {
console.log('成功取得回應:');
console.log(response.data);
})
.catch(error => {
console.error('發生錯誤,請檢查 API Key 與請求參數:');
console.error(error.response?.data || error.message);
});
import requests
url = "https://api.maiagent.ai/api/attachments/"
headers = {
"Authorization": "Api-Key YOUR_API_KEY"
}
response = requests.get(url, headers=headers)
try:
print("成功取得回應,數據如下:")
print(response.json())
except Exception as e:
print("發生錯誤,請檢查 API 請求:", e)
<?php
require 'vendor/autoload.php';
$client = new GuzzleHttpClient();
try {
$response = $client->get("https://api.maiagent.ai/api/attachments/", [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY'
]
]);
$data = json_decode($response->getBody(), true);
echo "成功取得回應:
";
print_r($data);
} catch (Exception $e) {
echo '錯誤, 請確認 API Key 與請求配置: ' . $e->getMessage();
}
?>
回應內容
{
"count": 0,
"next": "example_string",
"previous": "example_string",
"results": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": {},
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf"
}
]
}
取得指定附件內容
GET /api/attachments/{id}/
參數
參數名稱
必填
類型
說明
id
是
string
A UUID string identifying this attachment.
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X GET "https://api.maiagent.ai/api/attachments/550e8400-e29b-41d4-a716-446655440000/" \
-H "Authorization: Api-Key YOUR_API_KEY" \
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。
const axios = require('axios');
// 設定請求標頭 (請替換 YOUR_API_KEY)
const config = {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY'
}
};
axios.get("https://api.maiagent.ai/api/attachments/550e8400-e29b-41d4-a716-446655440000/", config)
.then(response => {
console.log('成功取得回應:');
console.log(response.data);
})
.catch(error => {
console.error('發生錯誤,請檢查 API Key 與請求參數:');
console.error(error.response?.data || error.message);
});
import requests
url = "https://api.maiagent.ai/api/attachments/550e8400-e29b-41d4-a716-446655440000/"
headers = {
"Authorization": "Api-Key YOUR_API_KEY"
}
response = requests.get(url, headers=headers)
try:
print("成功取得回應,數據如下:")
print(response.json())
except Exception as e:
print("發生錯誤,請檢查 API 請求:", e)
<?php
require 'vendor/autoload.php';
$client = new GuzzleHttpClient();
try {
$response = $client->get("https://api.maiagent.ai/api/attachments/550e8400-e29b-41d4-a716-446655440000/", [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY'
]
]);
$data = json_decode($response->getBody(), true);
echo "成功取得回應:
";
print_r($data);
} catch (Exception $e) {
echo '錯誤, 請確認 API Key 與請求配置: ' . $e->getMessage();
}
?>
回應內容
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": {},
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf"
}
更新附件資訊
PUT /api/attachments/{id}/
參數
參數名稱
必填
類型
說明
id
是
string
A UUID string identifying this attachment.
請求內容
{
"type": {},
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf"
}
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X PUT "https://api.maiagent.ai/api/attachments/550e8400-e29b-41d4-a716-446655440000/" \
-H "Authorization: Api-Key YOUR_API_KEY" \
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。
const axios = require('axios');
// 請求內容 (payload):
const data = {};
// 設定請求標頭
const config = {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY',
'Content-Type': 'application/json'
}
};
axios.put("https://api.maiagent.ai/api/attachments/550e8400-e29b-41d4-a716-446655440000/", data, config)
.then(response => {
console.log('成功取得回應,以下是數據:');
console.log(response.data);
})
.catch(error => {
console.error('請求發生錯誤,請檢查請求內容與 API Key:');
console.error(error.response?.data || error.message);
});
import requests
import json
url = "https://api.maiagent.ai/api/attachments/550e8400-e29b-41d4-a716-446655440000/"
headers = {
"Authorization": "Api-Key YOUR_API_KEY",
"Content-Type": "application/json"
}
# 請求內容 (payload)
data = {}
response = requests.put(url, json=data, headers=headers)
try:
print("成功取得回應,以下是返回數據:")
print(response.json())
except Exception as e:
print("請求出現錯誤,請檢查輸入參數與 API Key:", e)
<?php
require 'vendor/autoload.php';
$client = new GuzzleHttpClient();
try {
$response = $client->put("https://api.maiagent.ai/api/attachments/550e8400-e29b-41d4-a716-446655440000/", [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY',
'Content-Type' => 'application/json'
],
// 請求內容 (payload) 已包含在請求中
'json' => {}
]);
$data = json_decode($response->getBody(), true);
echo "成功取得回應:
";
print_r($data);
} catch (Exception $e) {
echo '發生錯誤, 請檢查請求細節及 API Key: ' . $e->getMessage();
}
?>
回應內容
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": {},
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf"
}
部分更新附件資料
PATCH /api/attachments/{id}/
參數
參數名稱
必填
類型
說明
id
是
string
A UUID string identifying this attachment.
請求內容
{
"type": {},
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf"
}
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X PATCH "https://api.maiagent.ai/api/attachments/550e8400-e29b-41d4-a716-446655440000/" \
-H "Authorization: Api-Key YOUR_API_KEY" \
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。
const axios = require('axios');
// 請求內容 (payload):
const data = {};
// 設定請求標頭
const config = {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY',
'Content-Type': 'application/json'
}
};
axios.patch("https://api.maiagent.ai/api/attachments/550e8400-e29b-41d4-a716-446655440000/", data, config)
.then(response => {
console.log('成功取得回應,以下是數據:');
console.log(response.data);
})
.catch(error => {
console.error('請求發生錯誤,請檢查請求內容與 API Key:');
console.error(error.response?.data || error.message);
});
import requests
import json
url = "https://api.maiagent.ai/api/attachments/550e8400-e29b-41d4-a716-446655440000/"
headers = {
"Authorization": "Api-Key YOUR_API_KEY",
"Content-Type": "application/json"
}
# 請求內容 (payload)
data = {}
response = requests.patch(url, json=data, headers=headers)
try:
print("成功取得回應,以下是返回數據:")
print(response.json())
except Exception as e:
print("請求出現錯誤,請檢查輸入參數與 API Key:", e)
<?php
require 'vendor/autoload.php';
$client = new GuzzleHttpClient();
try {
$response = $client->patch("https://api.maiagent.ai/api/attachments/550e8400-e29b-41d4-a716-446655440000/", [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY',
'Content-Type' => 'application/json'
],
// 請求內容 (payload) 已包含在請求中
'json' => {}
]);
$data = json_decode($response->getBody(), true);
echo "成功取得回應:
";
print_r($data);
} catch (Exception $e) {
echo '發生錯誤, 請檢查請求細節及 API Key: ' . $e->getMessage();
}
?>
回應內容
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": {},
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf"
}
刪除附件
DELETE /api/attachments/{id}/
參數
參數名稱
必填
類型
說明
id
是
string
A UUID string identifying this attachment.
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X DELETE "https://api.maiagent.ai/api/attachments/550e8400-e29b-41d4-a716-446655440000/" \
-H "Authorization: Api-Key YOUR_API_KEY" \
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。
const axios = require('axios');
// 請求內容 (payload):
const data = {};
// 設定請求標頭
const config = {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY',
'Content-Type': 'application/json'
}
};
axios.delete("https://api.maiagent.ai/api/attachments/550e8400-e29b-41d4-a716-446655440000/", data, config)
.then(response => {
console.log('成功取得回應,以下是數據:');
console.log(response.data);
})
.catch(error => {
console.error('請求發生錯誤,請檢查請求內容與 API Key:');
console.error(error.response?.data || error.message);
});
import requests
import json
url = "https://api.maiagent.ai/api/attachments/550e8400-e29b-41d4-a716-446655440000/"
headers = {
"Authorization": "Api-Key YOUR_API_KEY",
"Content-Type": "application/json"
}
# 請求內容 (payload)
data = {}
response = requests.delete(url, json=data, headers=headers)
try:
print("成功取得回應,以下是返回數據:")
print(response.json())
except Exception as e:
print("請求出現錯誤,請檢查輸入參數與 API Key:", e)
<?php
require 'vendor/autoload.php';
$client = new GuzzleHttpClient();
try {
$response = $client->delete("https://api.maiagent.ai/api/attachments/550e8400-e29b-41d4-a716-446655440000/", [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY',
'Content-Type' => 'application/json'
],
// 請求內容 (payload) 已包含在請求中
'json' => {}
]);
$data = json_decode($response->getBody(), true);
echo "成功取得回應:
";
print_r($data);
} catch (Exception $e) {
echo '發生錯誤, 請檢查請求細節及 API Key: ' . $e->getMessage();
}
?>
狀態碼
狀態碼
說明
204
No response body
Last updated
Was this helpful?