POST/api/v4/posts

创建公告帖子

创建 ANNOUNCEMENT 社交帖子,并将其发布到一个或多个地点的所选站点。

需要 API 密钥。请求头格式和密钥轮换请参阅身份验证。

参数

请求体

名称类型必填描述
inputobject必填Wrapper object. Every field below is a property of `input`, the entire body must be nested under it.
input.postNamestring必填Internal name for the campaign (not shown to customers).
input.locationIdsarray of strings必填Base64-encoded location IDs to publish to (e.g. `TG9jYXRpb246MTgwMDI4OQ==`).
input.postTypestring必填Must be `ANNOUNCEMENT`. One of EVENT, OFFER, ANNOUNCEMENT, COVID19, PRODUCT.
input.postSitesarray of strings必填Sites to publish to: `GOOGLE`, `FACEBOOK`.
input.postMessagearray of objects可选Per-site body text: `{ site, message }`. Provide one entry per site in `postSites`.
input.postCtaarray of objects可选Optional call-to-action button per site: `{ site, type, url }`. `type` is one of BOOK, ORDER, SHOP, LEARN_MORE, SIGN_UP, GET_OFFER.
input.postMediaUrlarray of objects可选Optional media per site: `{ site, url, type }` where `type` is IMAGE or VIDEO.
input.clientMutationIdstring可选Optional client token returned unchanged in the response for correlation.

请求示例

可直接粘贴的请求体。请将占位 ID 和值替换为您自己的。

Request body
{  "input": {    "postName": "Grand Opening Announcement",    "locationIds": ["TG9jYXRpb246MTgwMDI4OQ=="],    "postType": "ANNOUNCEMENT",    "postSites": ["GOOGLE"],    "postMessage": [      { "site": "GOOGLE", "message": "We are now open! Visit Jenny Home this week for our grand opening." }    ],    "postCta": [      { "site": "GOOGLE", "type": "LEARN_MORE", "url": "https://jennyhome.example/opening" }    ],    "postMediaUrl": [      { "site": "GOOGLE", "url": "https://cdn.example.com/opening.jpg", "type": "IMAGE" }    ]  }}

响应

200Post accepted. Publishing runs asynchronously, the returned post starts as INPROGRESS.
Response
{  "data": {    "createSocialPost": {      "clientMutationId": null,      "success": true,      "errors": [],      "socialPost": {        "id": "U29jaWFsUG9zdDo0NDEyMg==",        "name": "Grand Opening Announcement",        "status": "INPROGRESS",        "type": "ANNOUNCEMENT",        "createdAt": "2026-06-28",        "sites": ["GOOGLE"],        "message": [          { "site": "GOOGLE", "message": "We are now open! Visit Jenny Home this week for our grand opening." }        ],        "cta": [          { "type": { "value": "LEARN_MORE", "label": "Learn more" }, "url": "https://jennyhome.example/opening", "site": "GOOGLE", "tinyUrl": null }        ],        "contextInfo": null,        "mediaUrl": [          { "url": "https://cdn.example.com/opening.jpg", "site": "GOOGLE", "type": "IMAGE" }        ],        "publishDetails": [          { "site": "GOOGLE", "status": "PUBLISHING", "createdDate": "2026-06-28", "submissionError": null }        ],        "postLinks": [],        "locationIds": [1800289]      }    }  }}
400Bad request, the body was not wrapped in `input` (error message: `Variable "$input" of required type "CreateSocialPostMutationInput!" was not provided`).
401Unauthenticated, missing or invalid API key.

创建公告:最简单的帖子类型。公告包含一条纯文本消息(以及可选的 CTA 和图片),不包含活动日期或优惠详情。传入 postType: "ANNOUNCEMENT",并在 postSites 中为每个站点提供一个 postMessage 条目。

使用场景:在您的各家门店发布“我们开业了”。 通过一次调用,为一组地点向 Google(和 Facebook)发布盛大开业或新营业时间的公告。提供一个链接到您网站的 LEARN_MORE CTA 和一张图片,让卡片内容更丰富。调用会立即返回 status: INPROGRESS;使用返回的 socialPost.id 轮询 GET /posts/{postId},直到状态为 SUCCESS;如果有站点发布失败,请读取 publishDetails[].submissionError。

注意事项。

  • 请求体必须封装在 input 对象中:每个字段(postName、locationIds、postType、postSites 等)都是 input 的属性。未封装的扁平请求体会被拒绝,并返回 HTTP 400(Variable "$input" of required type "CreateSocialPostMutationInput!" was not provided)。
  • postSites 和每个 postMessage.site 都使用站点枚举(GOOGLE、FACEBOOK);请为每个目标站点提供一个消息条目。
  • 要将同一公告发布到多个地点,您可以在此处的 locationIds 中传入所有 ID,也可以使用 POST /bulk-posts 进行大规模多地点发布。
  • 对于带日期的帖子,请使用 活动;对于优惠券或折扣,请使用 优惠。

写入操作:未在实际账户中执行。所示请求和响应根据 API schema 构建;实际运行时,会向真实的 Google/Facebook 商家资料发布帖子。

Request
curl -X POST 'https://listingsapi.com/api/v4/posts' \  -H "Authorization: API $LISTINGSAPI_KEY" \  -H 'Content-Type: application/json' \  -d '{    "input": {      "postName": "Grand Opening Announcement",      "locationIds": [        "TG9jYXRpb246MTgwMDI4OQ=="      ],      "postType": "ANNOUNCEMENT",      "postSites": [        "GOOGLE"      ],      "postMessage": [        {          "site": "GOOGLE",          "message": "We are now open! Visit Jenny Home this week for our grand opening."        }      ],      "postCta": [        {          "site": "GOOGLE",          "type": "LEARN_MORE",          "url": "https://jennyhome.example/opening"        }      ],      "postMediaUrl": [        {          "site": "GOOGLE",          "url": "https://cdn.example.com/opening.jpg",          "type": "IMAGE"        }      ]    }  }'