curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/delegations \
-d '{"owners": [{"refId": "140b8709bd6ade099b242d895e268fb886130c53"}], "platforms": ["instagram"]}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/delegations", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
owners: [{ refId: "140b8709bd6ade099b242d895e268fb886130c53" }],
platforms: ["instagram"]
})
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
{
"status": "success",
"delegations": [
{
"id": "Kx3v9QpL2mZ7tR1wYb4N",
"owner": { "refId": "140b8709bd6ade099b242d895e268fb886130c53", "title": "Agent One" },
"payer": { "refId": "9f1c3e7a2b4d", "title": "Agency" },
"platform": "instagram",
"permission": "unknown",
"status": "active"
}
]
}
{
"action": "ads",
"status": "error",
"code": 400,
"message": "These owner profiles are not found in this account: 140b8709bd6ade."
}
Boost on Behalf
Tạo Ủy quyền Boost
Cho phép một profile trong tài khoản, bên thanh toán, boost bài đăng của profile khác bằng tài khoản quảng cáo của mình. Dùng API Key của Primary Profile.
POST
/
ads
/
delegations
curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/delegations \
-d '{"owners": [{"refId": "140b8709bd6ade099b242d895e268fb886130c53"}], "platforms": ["instagram"]}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/delegations", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
owners: [{ refId: "140b8709bd6ade099b242d895e268fb886130c53" }],
platforms: ["instagram"]
})
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
{
"status": "success",
"delegations": [
{
"id": "Kx3v9QpL2mZ7tR1wYb4N",
"owner": { "refId": "140b8709bd6ade099b242d895e268fb886130c53", "title": "Agent One" },
"payer": { "refId": "9f1c3e7a2b4d", "title": "Agency" },
"platform": "instagram",
"permission": "unknown",
"status": "active"
}
]
}
{
"action": "ads",
"status": "error",
"code": 400,
"message": "These owner profiles are not found in this account: 140b8709bd6ade."
}
Ủy quyền boost cho phép một profile trong tài khoản của bạn, gọi là bên thanh toán (payer), boost các bài đăng mà những profile khác trong tài khoản của bạn đã xuất bản. Bên thanh toán là profile có tài khoản quảng cáo chi trả cho quảng cáo.
Các ủy quyền được quản lý bằng API Key của Primary Profile. Gửi yêu cầu mà không kèm
Các profile được xác định bằng
Profile-Key.
Tham số Header
Tham số Body
Các User Profile (hồ sơ người dùng) có bài đăng mà bên thanh toán được phép boost. Có thể là danh sách tối đa 1.000 object có
refId, hoặc "all" cho mọi User Profile hiện có trong tài khoản của bạn, ngoại trừ bên thanh toán. Primary Profile của bạn không thể là chủ sở hữu (owner).Giới hạn 1.000 cũng áp dụng cho "all": nếu tài khoản của bạn có hơn 1.000 User Profile ngoài bên thanh toán, yêu cầu sẽ bị từ chối với code 101 và không có gì được tạo. Thay vào đó, hãy gửi owners dưới dạng danh sách tối đa 1.000 profile cho mỗi yêu cầu."all" không bao gồm các profile bạn tạo sau này. Hãy gửi lại yêu cầu để thêm chúng.Profile chi trả, dưới dạng một object có
refId. Bỏ qua tham số này để dùng Primary Profile của bạn.Các nền tảng quảng cáo cần ủy quyền, ví dụ
["instagram"]. Chỉ chấp nhận các mạng hỗ trợ quảng bá thay mặt hồ sơ khác; mạng khác sẽ trả về 101. Bạn nhận được một ủy quyền cho
mỗi chủ sở hữu và nền tảng.refId được trả về khi bạn tạo profile hoặc lấy danh sách profile.
Mỗi chủ sở hữu và nền tảng có một ủy quyền riêng, với id riêng. Gửi lại yêu cầu chỉ tạo các ủy quyền còn thiếu và trả về các ủy quyền hiện có mà không thay đổi. Có một ngoại lệ: nếu chủ sở hữu đã từ chối quyền trên mạng xã hội, permission của ủy quyền sẽ trở về unknown, để lần boost tiếp theo yêu cầu cấp quyền lại. Hãy gửi yêu cầu sau khi chủ sở hữu đã liên kết lại tài khoản. Một ủy quyền đã bị thu hồi cho một chủ sở hữu và nền tảng trong yêu cầu này sẽ hoạt động trở lại, với cùng id; các nền tảng đã bị thu hồi khác của chủ sở hữu vẫn giữ trạng thái thu hồi.
curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/delegations \
-d '{"owners": [{"refId": "140b8709bd6ade099b242d895e268fb886130c53"}], "platforms": ["instagram"]}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/delegations", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
owners: [{ refId: "140b8709bd6ade099b242d895e268fb886130c53" }],
platforms: ["instagram"]
})
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
{
"status": "success",
"delegations": [
{
"id": "Kx3v9QpL2mZ7tR1wYb4N",
"owner": { "refId": "140b8709bd6ade099b242d895e268fb886130c53", "title": "Agent One" },
"payer": { "refId": "9f1c3e7a2b4d", "title": "Agency" },
"platform": "instagram",
"permission": "unknown",
"status": "active"
}
]
}
{
"action": "ads",
"status": "error",
"code": 400,
"message": "These owner profiles are not found in this account: 140b8709bd6ade."
}