/api/v4/social/posts建立社群貼文
在品牌已連結的 Facebook、Instagram、X、LinkedIn 和 Pinterest 帳號上建立草稿、排程貼文或立即發布的貼文。
參數
請求主體
| 名稱 | 類型 | 必填 | 說明 |
|---|---|---|---|
| input | object | 必填 | Wrapper object. Every field below is a property of `input`, the entire body must be nested under it. |
| input.socialProfileId | string | 必填 | UUID of the brand publishing the post, the same value used as the `brandId` path token elsewhere. Every platform in `platforms` must already have a connection on this brand. |
| input.name | string | 必填 | Internal name for the post (not shown to the audience). Used to find it again in lists. |
| input.platforms | array of strings | 必填 | Platforms to publish to: `FACEBOOK`, `INSTAGRAM`, `TWITTER` (X), `LINKEDIN`, `PINTEREST`. |
| input.content | string | 必填 | The post body, published to every platform in `platforms`. |
| input.action | string | 必填 | `DRAFT` to save without publishing, `SCHEDULE` to publish at a future time (requires a schedule), or `PUBLISH` to publish now. |
| input.mediaUrls | array of strings | 選填 | Public https image URLs to attach. Instagram and Pinterest require at least one. |
| input.videoUrls | array of strings | 選填 | Public https video URLs to attach. |
| input.link | string | 選填 | Link to attach to the post where the platform supports one. |
| input.scheduledAt | string | 選填 | Publish time as an ISO-8601 timestamp with an offset, e.g. `2026-10-02T09:30:00-04:00`. Required when `action` is `SCHEDULE` unless you send `scheduleDate` + `scheduleTime`. Never send both forms. |
| input.scheduleDate | string | 選填 | Publish date as `YYYY-MM-DD`, interpreted in the **brand's** timezone. Must be sent together with `scheduleTime`. |
| input.scheduleTime | string | 選填 | Publish time as `HH:MM` (24-hour), interpreted in the **brand's** timezone. Must be sent together with `scheduleDate`. |
| input.connectedChannelIds | array of strings | 選填 | Restrict publishing to specific connections by their `id` from the connections list. Defaults to the brand's active connection for each platform in `platforms`. |
| input.clientReference | string | 選填 | Your own identifier for this post, stored and echoed back. Use it to reconcile the post against your own records without holding onto the returned UUID. |
請求範例
可直接貼上的請求主體。請將預留位置 ID 與值換成您自己的。
{ "input": { "socialProfileId": "6f2c9a41-7b0e-4d55-9a2f-3c8e1d47b902", "name": "Autumn collection launch", "platforms": ["INSTAGRAM", "FACEBOOK", "LINKEDIN"], "content": "Our autumn collection lands today. Solid oak, hand-finished, made two blocks from the shop. Come see it in person this weekend.", "mediaUrls": ["https://cdn.example.com/social/autumn-collection.jpg"], "link": "https://jennyhome.example/autumn", "action": "SCHEDULE", "scheduleDate": "2026-10-02", "scheduleTime": "09:30", "clientReference": "campaign-4471-slot-01" }}回應
200Post accepted. Publishing runs asynchronously, poll GET /social/posts/{postId} for per-channel status.
{ "data": { "createSimpleSocialMediaPost": { "success": true, "error": [], "socialPostId": "c47a1e58-2b93-4f10-a6d7-58e0c9b12345", "status": "SCHEDULED" } }}200Validation failed. Nothing was created. The status is still 200: read `success` and the `error` array.
{ "data": { "createSimpleSocialMediaPost": { "success": false, "error": [ { "message": "SY95045: No connected channel for PINTEREST on this brand", "code": "SY95045", "contextInfo": [{ "key": "platform", "value": "PINTEREST" }] }, { "message": "SY95046: scheduleTime must be HH:MM in the brand's timezone", "code": "SY95046", "contextInfo": null } ], "socialPostId": null, "status": null } }}401Unauthenticated, missing or invalid API key.
404No brand with that ID on this account (`SY95043`).
為一個品牌建立一則貼文,涵蓋該品牌已連結的一個或多個社群帳號。同一次呼叫可處理全部 3 種生命週期:儲存 DRAFT、將 SCHEDULE 加入佇列,或立即 PUBLISH。
使用案例:從您自己的行事曆排程行銷活動。您的應用程式已知道客戶想發布的內容與時間。針對每個時段,使用 action: "SCHEDULE" 搭配 scheduledAt 或 scheduleDate + scheduleTime 呼叫此端點,並將您自己的時段識別碼作為 clientReference 傳入,讓您無須儲存傳回的 UUID 即可核對。在 GET /social/posts/{postId} 回報所有管道皆已上線之前,將該項目顯示為待處理,並提供一個串接至 POST /social/posts/cancel 的取消按鈕。
發布作業以非同步方式執行
action: "PUBLISH" 不會在回傳回應前發布貼文。此呼叫會接受貼文、傳回 socialPostId,並將貼文交給發布流程處理。若要確認實際結果,請輪詢 GET /social/posts/{postId} 並讀取各管道的 channels[] 陣列:每個項目的 status 代表該平台的處理結果。同一個請求中的貼文可能在 Instagram 發布成功,卻在 LinkedIn 發布失敗,因此應以 channels[] 為準,貼文層級的 status 則是摘要。
選擇排程方式
action: "SCHEDULE" 必須且只能使用以下 2 種形式之一,絕不可同時使用:
若同時傳送兩種形式、傳送 scheduleDate 卻未傳送 scheduleTime,或傳送不含時區偏移量的 scheduledAt,請求都會遭到拒絕並傳回 SY95046。DRAFT 和 PUBLISH 完全不得包含排程。
注意事項。
- 請求主體必須包在
input物件中。 - 請檢查
success,而非 HTTP 狀態。驗證失敗時會傳回HTTP 200,其中包含success: false,且error陣列中每個問題各有一個項目。當success為false時,不會建立任何內容。 - 請求主體以
socialProfileId識別品牌。brandId只會是 URL 路徑中的佔位符,絕不會是請求主體欄位。 platforms中的每個平台都必須已與該品牌建立連線。若平台沒有有效的管道,請求會失敗並傳回SY95045;請先讀取品牌的連線,並引導使用者透過連線連結補上任何缺少的連線。- 平台值為大寫列舉名稱
FACEBOOK、INSTAGRAM、TWITTER、LINKEDIN、PINTEREST。TWITTER代表 X;此值保留了舊名稱,小寫值會遭到拒絕。 - Instagram 和 Pinterest 不接受純文字貼文:當
platforms包含其中任一平台時,請提供至少 1 個mediaUrls項目。 - 貼文 ID 是一般 UUID,而非地點貼文使用的 Base64 relay ID。
- 若要一次建立較多貼文,請使用
POST /social/bulk-posts,它接受相同的資料列結構,並會預先驗證整個批次。
寫入操作:未對正式帳戶執行。此處顯示的請求與回應是依據 API 結構描述建構的;執行時會發布至真實的社群帳號。
curl -X POST 'https://listingsapi.com/api/v4/social/posts' \ -H "Authorization: API $LISTINGSAPI_KEY" \ -H 'Content-Type: application/json' \ -d '{ "input": { "socialProfileId": "6f2c9a41-7b0e-4d55-9a2f-3c8e1d47b902", "name": "Autumn collection launch", "platforms": [ "INSTAGRAM", "FACEBOOK", "LINKEDIN" ], "content": "Our autumn collection lands today. Solid oak, hand-finished, made two blocks from the shop. Come see it in person this weekend.", "mediaUrls": [ "https://cdn.example.com/social/autumn-collection.jpg" ], "link": "https://jennyhome.example/autumn", "action": "SCHEDULE", "scheduleDate": "2026-10-02", "scheduleTime": "09:30", "clientReference": "campaign-4471-slot-01" } }'