curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"name": "Spring promo (updated)",
"active": true,
"actions": [
{
"type": "send_dm",
"message": "Hey {{recipient_username}}! New link: https://example.com/spring"
}
]
}' \
-X PUT https://api.ayrshare.com/api/automations/auto_9xKp2Lm4nQ
const API_KEY = "API_KEY";
const id = "auto_9xKp2Lm4nQ";
fetch(`https://api.ayrshare.com/api/automations/${id}`, {
method: "PUT",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Spring promo (updated)",
active: true,
actions: [
{
type: "send_dm",
message: "Hey {{recipient_username}}! New link: https://example.com/spring",
},
],
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
headers = {
"Authorization": "Bearer API_KEY",
"Content-Type": "application/json",
}
automation_id = "auto_9xKp2Lm4nQ"
payload = {
"name": "Spring promo (updated)",
"active": True,
"actions": [
{
"type": "send_dm",
"message": "Hey {{recipient_username}}! New link: https://example.com/spring",
}
],
}
r = requests.put(
f"https://api.ayrshare.com/api/automations/{automation_id}",
json=payload,
headers=headers,
)
print(r.json())
$id = "auto_9xKp2Lm4nQ";
$data = [
"name" => "Spring promo (updated)",
"active" => true,
"actions" => [
[
"type" => "send_dm",
"message" => "Hey {{recipient_username}}! New link: https://example.com/spring",
],
],
];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ayrshare.com/api/automations/" . $id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer API_KEY",
"Content-Type: application/json",
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
{
"status": "success",
"id": "auto_9xKp2Lm4nQ"
}
{
"action": "request",
"status": "error",
"code": 473,
"message": "Validation failed. Please see: https://www.ayrshare.com/docs/introduction",
"details": {
"formErrors": ["Unrecognized key: \"platform\""],
"fieldErrors": {}
}
}
{
"action": "automation",
"status": "error",
"code": 469,
"message": "Automation not found"
}
{
"action": "automation",
"status": "error",
"code": 470,
"message": "Active automation limit reached for your plan tier"
}
Automations
更新自動化
更新既有的自動化
PUT
/
automations
/
:id
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"name": "Spring promo (updated)",
"active": true,
"actions": [
{
"type": "send_dm",
"message": "Hey {{recipient_username}}! New link: https://example.com/spring"
}
]
}' \
-X PUT https://api.ayrshare.com/api/automations/auto_9xKp2Lm4nQ
const API_KEY = "API_KEY";
const id = "auto_9xKp2Lm4nQ";
fetch(`https://api.ayrshare.com/api/automations/${id}`, {
method: "PUT",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Spring promo (updated)",
active: true,
actions: [
{
type: "send_dm",
message: "Hey {{recipient_username}}! New link: https://example.com/spring",
},
],
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
headers = {
"Authorization": "Bearer API_KEY",
"Content-Type": "application/json",
}
automation_id = "auto_9xKp2Lm4nQ"
payload = {
"name": "Spring promo (updated)",
"active": True,
"actions": [
{
"type": "send_dm",
"message": "Hey {{recipient_username}}! New link: https://example.com/spring",
}
],
}
r = requests.put(
f"https://api.ayrshare.com/api/automations/{automation_id}",
json=payload,
headers=headers,
)
print(r.json())
$id = "auto_9xKp2Lm4nQ";
$data = [
"name" => "Spring promo (updated)",
"active" => true,
"actions" => [
[
"type" => "send_dm",
"message" => "Hey {{recipient_username}}! New link: https://example.com/spring",
],
],
];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ayrshare.com/api/automations/" . $id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer API_KEY",
"Content-Type: application/json",
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
{
"status": "success",
"id": "auto_9xKp2Lm4nQ"
}
{
"action": "request",
"status": "error",
"code": 473,
"message": "Validation failed. Please see: https://www.ayrshare.com/docs/introduction",
"details": {
"formErrors": ["Unrecognized key: \"platform\""],
"fieldErrors": {}
}
}
{
"action": "automation",
"status": "error",
"code": 469,
"message": "Automation not found"
}
{
"action": "automation",
"status": "error",
"code": 470,
"message": "Active automation limit reached for your plan tier"
}
Beta。 完整功能說明請見自動化概觀。
platform、accountId)會被視為驗證錯誤而拒絕。
傳入 triggers 或 actions 會原子性地取代既有的子項目:舊的集合會被刪除,新的集合會在同一個 Firestore 交易中寫入。若只想變更一個 trigger,請傳入完整的新陣列。
重新啟用先前未啟用的自動化(active: true)會重新檢查使用中自動化上限。若已達上限,更新會以代碼 470 失敗,且不會有任何變更。
標頭參數
路徑參數
由
POST /automations 回傳的自動化 ID。主體參數
新名稱。
新描述。
切換自動化的啟用狀態。若將此欄位由
false 改為 true,會重新檢查使用中自動化上限。完整取代的觸發條件集合(1–50 個)。格式與建立端點相同。
完整取代的動作集合(1–50 個)。格式與建立端點相同。
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"name": "Spring promo (updated)",
"active": true,
"actions": [
{
"type": "send_dm",
"message": "Hey {{recipient_username}}! New link: https://example.com/spring"
}
]
}' \
-X PUT https://api.ayrshare.com/api/automations/auto_9xKp2Lm4nQ
const API_KEY = "API_KEY";
const id = "auto_9xKp2Lm4nQ";
fetch(`https://api.ayrshare.com/api/automations/${id}`, {
method: "PUT",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Spring promo (updated)",
active: true,
actions: [
{
type: "send_dm",
message: "Hey {{recipient_username}}! New link: https://example.com/spring",
},
],
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
headers = {
"Authorization": "Bearer API_KEY",
"Content-Type": "application/json",
}
automation_id = "auto_9xKp2Lm4nQ"
payload = {
"name": "Spring promo (updated)",
"active": True,
"actions": [
{
"type": "send_dm",
"message": "Hey {{recipient_username}}! New link: https://example.com/spring",
}
],
}
r = requests.put(
f"https://api.ayrshare.com/api/automations/{automation_id}",
json=payload,
headers=headers,
)
print(r.json())
$id = "auto_9xKp2Lm4nQ";
$data = [
"name" => "Spring promo (updated)",
"active" => true,
"actions" => [
[
"type" => "send_dm",
"message" => "Hey {{recipient_username}}! New link: https://example.com/spring",
],
],
];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ayrshare.com/api/automations/" . $id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer API_KEY",
"Content-Type: application/json",
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
{
"status": "success",
"id": "auto_9xKp2Lm4nQ"
}
{
"action": "request",
"status": "error",
"code": 473,
"message": "Validation failed. Please see: https://www.ayrshare.com/docs/introduction",
"details": {
"formErrors": ["Unrecognized key: \"platform\""],
"fieldErrors": {}
}
}
{
"action": "automation",
"status": "error",
"code": 469,
"message": "Automation not found"
}
{
"action": "automation",
"status": "error",
"code": 470,
"message": "Active automation limit reached for your plan tier"
}
⌘I
