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
Bulk Post
Lên lịch hàng loạt bài đăng với tệp 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"
}
]
}
Lên lịch hàng loạt bài đăng bằng tệp CSV (Comma Separated Values) chứa dữ liệu các bài đăng.
Content-Type phải là
multipart/form-data.
Chúng tôi khuyến nghị sử dụng endpoint Post trực tiếp thay vì phương thức bulk này để
lên lịch bài đăng. Endpoint trực tiếp cung cấp bộ tính năng toàn diện hơn và khả năng
gỡ lỗi dễ dàng hơn.
Tham số Header
string
bắt buộc
Định dạng:
Authorization: Bearer API_KEY. Xem tổng quan API để biết thêm
thông tin.string
Profile Key của một user profile.
string
bắt buộc
Content-Type: multipart/form-dataTham số Body
Ví dụ Request
Một multipart form-data chứa tệp CSV các bài đăng sẽ lên lịch chúng cho một ngày trong tương lai. Tệp CSV chứa các trường sau (mẫu bên dưới) và đều bắt buộc:post: Nội dung bài đăng.platforms: Danh sách các nền tảng phân tách bằng dấu phẩy, ví dụ: “twitter, facebook, instagram”.mediaUrls: URL của phương tiện, chẳng hạn như hình ảnh hoặc video để bao gồm trong bài đăng.scheduleDate: Thời gian lên lịch bài đăng theo định dạng UTC. Ví dụ, dùng định dạngYYYY-MM-DDThh:mm:ssZvà gửi dưới dạng2026-07-08T12:30:00Z. Vui lòng xem utctime để biết thêm ví dụ.
Không lên lịch các bài đăng trùng lặp cách nhau chưa đến 24 giờ.Mỗi bài đăng sẽ được kiểm tra trong khung 48 giờ lấy chính
scheduleDate của nó làm tâm — 24 giờ trước và 24 giờ sau. Nếu trong khung đó có một bài đăng khác với nội dung giống hệt hoặc gần giống, bài đăng sẽ bị từ chối với lỗi 137. Khung này nhìn cả về phía trước lẫn phía sau, nên một dòng có thể bị từ chối vì một dòng được lên lịch sau nó. Việc kiểm tra diễn ra ngay khi bài đăng được gửi hoặc lên lịch, chứ không chỉ ngay trước khi đăng.
Điều này nhằm bảo vệ tài khoản của bạn tại các mạng xã hội; họ có thể tạm ngưng hoặc shadow-ban các tài khoản đăng trùng lặp thường xuyên.Mẫu CSV
Tải xuống mẫu và lưu dưới dạng tệp .csv. Mẫu CSV Ayrsharecurl \
-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"
}
]
}