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 nhiều bài đăng cùng lúc bằng cách tải tệp CSV dạng multipart/form-data. Gồm các trường bắt buộc, quy tắc về bài đăng trùng lặp và mẫu CSV.
POST
/
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"
}
]
}
Targeting X/Twitter? Starting March 31, 2026, all X operations require your own API credentials. After linking X via OAuth, include these 2 headers in your request:
One-time setup per Ayrshare account. You create one X Developer App and reuse the same API Key and Secret across every sub-profile / end-user you link. You do not create a new app per customer.
Not linked yet? See the full setup guide to connect your X account.
Your keys are never logged or stored by Ayrshare.
X-Twitter-OAuth1-Api-Key — Your API Key (Consumer Key)X-Twitter-OAuth1-Api-Secret — Your API Key Secret (Consumer Secret)One-time setup per Ayrshare account. You create one X Developer App and reuse the same API Key and Secret across every sub-profile / end-user you link. You do not create a new app per customer.
Not linked yet? See the full setup guide to connect your X account.
Your keys are never logged or stored by Ayrshare.
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
Định dạng:
Authorization: Bearer API_KEY. Xem tổng quan API để biết thêm
thông tin.Tham số Body
Tệp CSV multipart form-data chứa các bài đăng đã lên lịch. Xem bên dưới để biết mẫu CSV.
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"
}
]
}