curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"id": "s8k2jsk0pl", "scheduleDate": "2023-07-08T12:30:00Z", scheduledPause: true}' \
-X PATCH https://api.ayrshare.com/api/post
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/post", {
method: "PATCH",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
id: "s8k2jsk0pl", // required
scheduleDate: "2023-07-08T12:30:00Z",
scheduledPause: true
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {'id': 's8k2jsk0pl',
'scheduleDate': '2023-07-08T12:30:00Z'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.patch('https://api.ayrshare.com/api/post',
json=payload,
headers=headers)
print(r.json())
<?php
$apiUrl = 'https://api.ayrshare.com/api/post';
$apiKey = 'API_KEY'; // Replace 'API_KEY' with your actual API key
$headers = [
'Content-Type: application/json',
'Authorization: Bearer ' . $apiKey,
];
$data = json_encode([
'id' => 's8k2jsk0pl', // Replace with your actual post ID
'scheduleDate' => '2023-07-08T12:30:00Z'
]);
$curl = curl_init($apiUrl);
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => $data
]);
$response = curl_exec($curl);
if ($response === false) {
echo 'Curl error: ' . curl_error($curl);
} else {
echo json_encode(json_decode($response), JSON_PRETTY_PRINT);
}
curl_close($curl);
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace PostUpdatePOSTRequest_csharp
{
class PostUpdate
{
static async Task Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://api.ayrshare.com/api/post";
using (var httpClient = new HttpClient())
{
try
{
httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);
string json = "{\"id\":\"s8k2jsk0pl\"," +
"\"scheduleDate\":\"2023-07-08T12:30:00Z\"}";
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await httpClient.PatchAsync(url, content);
var responseBody = await response.Content.ReadAsStringAsync();
response.EnsureSuccessStatusCode();
Console.WriteLine(responseBody);
}
catch (HttpRequestException ex)
{
Console.WriteLine("Error: " + ex.Message);
if (ex.InnerException != null)
{
Console.WriteLine("Error details: " + ex.InnerException.Message);
}
}
}
}
}
}
package main
import (
"bytes"
"encoding/json"
"log"
"net/http"
)
func main() {
message := map[string]interface{}{
"id": "s8k2jsk0pl",
"scheduleDate": "2023-07-08T12:30:00Z"
}
bytesRepresentation, err := json.Marshal(message)
if err != nil {
log.Fatalln(err)
}
req, _ := http.NewRequest("PATCH", "https://api.ayrshare.com/api/post",
bytes.NewBuffer(bytesRepresentation))
req.Header.Add("Content-Type", "application/json; charset=UTF-8")
req.Header.Add("Authorization", "Bearer API_KEY")
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal("Error:", err)
}
res.Body.Close()
}
{
"status": "success",
"id": "ZSU1tnnuykDy25wA6kvX", // Ayrshare Post ID
"scheduleDate": "2025-07-08T12:30:00Z",
"scheduledPaused": true
}
{
"action": "update",
"status": "error",
"code": 305,
"message": "Error updating post. Post ID not found."
}on
{
"action": "post",
"status": "error",
"code": 104,
"message": "Invalid schedule date format for scheduleDate. .../ayrshare.com/rest-api/endpoints/post#send-a-post"
}
Post
更新貼文
更新已排程貼文的中繼資料
PATCH
/
post
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"id": "s8k2jsk0pl", "scheduleDate": "2023-07-08T12:30:00Z", scheduledPause: true}' \
-X PATCH https://api.ayrshare.com/api/post
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/post", {
method: "PATCH",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
id: "s8k2jsk0pl", // required
scheduleDate: "2023-07-08T12:30:00Z",
scheduledPause: true
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {'id': 's8k2jsk0pl',
'scheduleDate': '2023-07-08T12:30:00Z'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.patch('https://api.ayrshare.com/api/post',
json=payload,
headers=headers)
print(r.json())
<?php
$apiUrl = 'https://api.ayrshare.com/api/post';
$apiKey = 'API_KEY'; // Replace 'API_KEY' with your actual API key
$headers = [
'Content-Type: application/json',
'Authorization: Bearer ' . $apiKey,
];
$data = json_encode([
'id' => 's8k2jsk0pl', // Replace with your actual post ID
'scheduleDate' => '2023-07-08T12:30:00Z'
]);
$curl = curl_init($apiUrl);
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => $data
]);
$response = curl_exec($curl);
if ($response === false) {
echo 'Curl error: ' . curl_error($curl);
} else {
echo json_encode(json_decode($response), JSON_PRETTY_PRINT);
}
curl_close($curl);
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace PostUpdatePOSTRequest_csharp
{
class PostUpdate
{
static async Task Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://api.ayrshare.com/api/post";
using (var httpClient = new HttpClient())
{
try
{
httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);
string json = "{\"id\":\"s8k2jsk0pl\"," +
"\"scheduleDate\":\"2023-07-08T12:30:00Z\"}";
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await httpClient.PatchAsync(url, content);
var responseBody = await response.Content.ReadAsStringAsync();
response.EnsureSuccessStatusCode();
Console.WriteLine(responseBody);
}
catch (HttpRequestException ex)
{
Console.WriteLine("Error: " + ex.Message);
if (ex.InnerException != null)
{
Console.WriteLine("Error details: " + ex.InnerException.Message);
}
}
}
}
}
}
package main
import (
"bytes"
"encoding/json"
"log"
"net/http"
)
func main() {
message := map[string]interface{}{
"id": "s8k2jsk0pl",
"scheduleDate": "2023-07-08T12:30:00Z"
}
bytesRepresentation, err := json.Marshal(message)
if err != nil {
log.Fatalln(err)
}
req, _ := http.NewRequest("PATCH", "https://api.ayrshare.com/api/post",
bytes.NewBuffer(bytesRepresentation))
req.Header.Add("Content-Type", "application/json; charset=UTF-8")
req.Header.Add("Authorization", "Bearer API_KEY")
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal("Error:", err)
}
res.Body.Close()
}
{
"status": "success",
"id": "ZSU1tnnuykDy25wA6kvX", // Ayrshare Post ID
"scheduleDate": "2025-07-08T12:30:00Z",
"scheduledPaused": true
}
{
"action": "update",
"status": "error",
"code": 305,
"message": "Error updating post. Post ID not found."
}on
{
"action": "post",
"status": "error",
"code": 104,
"message": "Invalid schedule date format for scheduleDate. .../ayrshare.com/rest-api/endpoints/post#send-a-post"
}
更新貼文的
scheduleDate、approval 審核狀態、notes,或已發布 YouTube 影片的 visibility。
- 貼文原本必須有
scheduleDate且status為 “pending”。你可以透過 /history 或 GET /post 端點來查詢status。 - YouTube 影片必須已成功發布,才能變更其可見性。
- 審核流程要求貼文目前的狀態為 “awaiting approval”。
Header 參數
Body 參數
若原始貼文需要審核,且狀態為 “awaiting approval”,將此參數設為
true 即可核准並發布該貼文。啟用或停用貼文的留言功能。設為
true 會停用留言;設為 false 則會啟用留言。支援的平台:Instagram 與 LinkedIn。- 不論是排程貼文或已發布的貼文,都可以啟用或停用留言。
- 對已發布的貼文停用留言,不會刪除既有的留言。
- 停用 LinkedIn 留言會刪除該討論串上的所有既有留言。
- Instagram 的留言不會被刪除。
- TikTok 的留言在發布後就無法變更。
排程未來貼文的
datetime。接受 UTC 日期時間。例如使用 YYYY-MM-DDThh:mm:ssZ 格式,並以 2026-07-08T12:30:00Z 的形式傳送。
更多範例請參閱 utctime。如果 datetime 為過去時間,該貼文會立即發送。
暫停或取消暫停一則排程貼文。若貼文被取消暫停時,
scheduleDate 已是過去時間,
該貼文會立即發布。建議在取消暫停前先更新 scheduleDate。透過
visibility 欄位更新 YouTube 影片的可見性,可用的值有 unlisted、private 或 public。也可以更新 description、title 或 categoryId。若原本未設定 description 或 categoryId,預設值分別為 "" 與 24(Entertainment)。curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"id": "s8k2jsk0pl", "scheduleDate": "2023-07-08T12:30:00Z", scheduledPause: true}' \
-X PATCH https://api.ayrshare.com/api/post
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/post", {
method: "PATCH",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
id: "s8k2jsk0pl", // required
scheduleDate: "2023-07-08T12:30:00Z",
scheduledPause: true
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {'id': 's8k2jsk0pl',
'scheduleDate': '2023-07-08T12:30:00Z'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.patch('https://api.ayrshare.com/api/post',
json=payload,
headers=headers)
print(r.json())
<?php
$apiUrl = 'https://api.ayrshare.com/api/post';
$apiKey = 'API_KEY'; // Replace 'API_KEY' with your actual API key
$headers = [
'Content-Type: application/json',
'Authorization: Bearer ' . $apiKey,
];
$data = json_encode([
'id' => 's8k2jsk0pl', // Replace with your actual post ID
'scheduleDate' => '2023-07-08T12:30:00Z'
]);
$curl = curl_init($apiUrl);
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => $data
]);
$response = curl_exec($curl);
if ($response === false) {
echo 'Curl error: ' . curl_error($curl);
} else {
echo json_encode(json_decode($response), JSON_PRETTY_PRINT);
}
curl_close($curl);
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace PostUpdatePOSTRequest_csharp
{
class PostUpdate
{
static async Task Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://api.ayrshare.com/api/post";
using (var httpClient = new HttpClient())
{
try
{
httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);
string json = "{\"id\":\"s8k2jsk0pl\"," +
"\"scheduleDate\":\"2023-07-08T12:30:00Z\"}";
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await httpClient.PatchAsync(url, content);
var responseBody = await response.Content.ReadAsStringAsync();
response.EnsureSuccessStatusCode();
Console.WriteLine(responseBody);
}
catch (HttpRequestException ex)
{
Console.WriteLine("Error: " + ex.Message);
if (ex.InnerException != null)
{
Console.WriteLine("Error details: " + ex.InnerException.Message);
}
}
}
}
}
}
package main
import (
"bytes"
"encoding/json"
"log"
"net/http"
)
func main() {
message := map[string]interface{}{
"id": "s8k2jsk0pl",
"scheduleDate": "2023-07-08T12:30:00Z"
}
bytesRepresentation, err := json.Marshal(message)
if err != nil {
log.Fatalln(err)
}
req, _ := http.NewRequest("PATCH", "https://api.ayrshare.com/api/post",
bytes.NewBuffer(bytesRepresentation))
req.Header.Add("Content-Type", "application/json; charset=UTF-8")
req.Header.Add("Authorization", "Bearer API_KEY")
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal("Error:", err)
}
res.Body.Close()
}
{
"status": "success",
"id": "ZSU1tnnuykDy25wA6kvX", // Ayrshare Post ID
"scheduleDate": "2025-07-08T12:30:00Z",
"scheduledPaused": true
}
{
"action": "update",
"status": "error",
"code": 305,
"message": "Error updating post. Post ID not found."
}on
{
"action": "post",
"status": "error",
"code": 104,
"message": "Invalid schedule date format for scheduleDate. .../ayrshare.com/rest-api/endpoints/post#send-a-post"
}
⌘I
