curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: multipart/form-data' \
-F 'file=@"./Ayrshare CSV Template.csv"' \
-X POST https://api.ayrshare.com/api/post/bulk
const API_KEY = "API_KEY";
const FormData = require("form-data");
const fs = require("fs");
const formData = new FormData();
formData.append("file", fs.createReadStream("./Ayrshare CSV Template.csv"));
fetch("https://api.ayrshare.com/api/post/bulk", {
method: "POST",
headers: {
Authorization: `Bearer ${API_KEY}`,
...formData.getHeaders()
},
body: formData
})
.then((res) => res.json())
.then((data) => {
console.log(JSON.stringify(data));
})
.catch((error) => {
console.log(error);
});
import requests
API_KEY = "API_KEY"
# Open the CSV file in binary read mode
with open('./Ayrshare CSV Template.csv', 'rb') as file:
# Prepare the files dictionary for the multipart/form-data request
files = {'file': file}
# Set up the authorization header
headers = {'Authorization': f'Bearer {API_KEY}'}
try:
# Make the POST request to the API
response = requests.post(
'https://api.ayrshare.com/api/post/bulk',
headers=headers,
files=files
)
# Parse and print the JSON response
data = response.json()
print(data)
except Exception as e:
print(f"Error: {e}")
{
"status": "success",
"posts": [
{
"status": "scheduled",
"scheduleDate": "4/6/21 12:50",
"id": "X3uTExuEJhyM3u8wCRsA",
"post": "A great post"
},
{
"status": "scheduled",
"scheduleDate": "4/6/21 13:00",
"id": "8RGrekuxMnVa7lVnARFm",
"post": "An even better post"
}
]
}
Post
批次發布
使用 CSV 檔案批次排程多則貼文
PUT
/
post
/
bulk
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: multipart/form-data' \
-F 'file=@"./Ayrshare CSV Template.csv"' \
-X POST https://api.ayrshare.com/api/post/bulk
const API_KEY = "API_KEY";
const FormData = require("form-data");
const fs = require("fs");
const formData = new FormData();
formData.append("file", fs.createReadStream("./Ayrshare CSV Template.csv"));
fetch("https://api.ayrshare.com/api/post/bulk", {
method: "POST",
headers: {
Authorization: `Bearer ${API_KEY}`,
...formData.getHeaders()
},
body: formData
})
.then((res) => res.json())
.then((data) => {
console.log(JSON.stringify(data));
})
.catch((error) => {
console.log(error);
});
import requests
API_KEY = "API_KEY"
# Open the CSV file in binary read mode
with open('./Ayrshare CSV Template.csv', 'rb') as file:
# Prepare the files dictionary for the multipart/form-data request
files = {'file': file}
# Set up the authorization header
headers = {'Authorization': f'Bearer {API_KEY}'}
try:
# Make the POST request to the API
response = requests.post(
'https://api.ayrshare.com/api/post/bulk',
headers=headers,
files=files
)
# Parse and print the JSON response
data = response.json()
print(data)
except Exception as e:
print(f"Error: {e}")
{
"status": "success",
"posts": [
{
"status": "scheduled",
"scheduleDate": "4/6/21 12:50",
"id": "X3uTExuEJhyM3u8wCRsA",
"post": "A great post"
},
{
"status": "scheduled",
"scheduleDate": "4/6/21 13:00",
"id": "8RGrekuxMnVa7lVnARFm",
"post": "An even better post"
}
]
}
以貼文資料的 CSV(Comma Separated Values)檔案批次排程多則貼文。
Content-Type 必須為
multipart/form-data。
排程貼文時,我們建議直接使用 Post 端點,而非此批次方法。
Post 端點提供更完整的功能集,也更容易進行除錯。
Header 參數
User Profile 的 Profile Key。
Content-Type: multipart/form-dataBody 參數
請求範例
包含貼文 CSV 檔案的 multipart form-data 會將貼文排程到未來的日期發布。 CSV 檔案包含以下必填欄位(範本如下):post:貼文文字。platforms:以逗號分隔的平台清單,例如 “twitter, facebook, instagram”。mediaUrls:貼文要包含的媒體(例如圖片或影片)URL。scheduleDate:以 UTC 格式表示的排程日期時間。例如使用YYYY-MM-DDThh:mm:ssZ格式,並以2026-07-08T12:30:00Z的形式傳送。更多範例請參閱 utctime。
不要在少於兩天的間隔內傳送重複的貼文。如果兩則文字完全相同的貼文,其 scheduleDate 間隔少於三天,則第二則貼文在其 scheduleDate 到期時將被拒絕。
這是為了保護你在各平台的帳號安全;平台可能會停權或降低頻繁發布重複內容的帳號的觸及率。
CSV 範本
下載範本並另存為 .csv 檔案。 Ayrshare CSV 範本curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: multipart/form-data' \
-F 'file=@"./Ayrshare CSV Template.csv"' \
-X POST https://api.ayrshare.com/api/post/bulk
const API_KEY = "API_KEY";
const FormData = require("form-data");
const fs = require("fs");
const formData = new FormData();
formData.append("file", fs.createReadStream("./Ayrshare CSV Template.csv"));
fetch("https://api.ayrshare.com/api/post/bulk", {
method: "POST",
headers: {
Authorization: `Bearer ${API_KEY}`,
...formData.getHeaders()
},
body: formData
})
.then((res) => res.json())
.then((data) => {
console.log(JSON.stringify(data));
})
.catch((error) => {
console.log(error);
});
import requests
API_KEY = "API_KEY"
# Open the CSV file in binary read mode
with open('./Ayrshare CSV Template.csv', 'rb') as file:
# Prepare the files dictionary for the multipart/form-data request
files = {'file': file}
# Set up the authorization header
headers = {'Authorization': f'Bearer {API_KEY}'}
try:
# Make the POST request to the API
response = requests.post(
'https://api.ayrshare.com/api/post/bulk',
headers=headers,
files=files
)
# Parse and print the JSON response
data = response.json()
print(data)
except Exception as e:
print(f"Error: {e}")
{
"status": "success",
"posts": [
{
"status": "scheduled",
"scheduleDate": "4/6/21 12:50",
"id": "X3uTExuEJhyM3u8wCRsA",
"post": "A great post"
},
{
"status": "scheduled",
"scheduleDate": "4/6/21 13:00",
"id": "8RGrekuxMnVa7lVnARFm",
"post": "An even better post"
}
]
}
⌘I
