/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 种形式之一,不能同时使用:
同时发送这 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 schema 构建;实际运行时,会向真实社交账号发布内容。
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" } }'