POST/api/v4/posts

创建活动帖子

创建包含标题和开始/结束时间范围的 EVENT 社交帖子,并将其发布到一个或多个地点的所选站点。

需要 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 `EVENT`. One of EVENT, OFFER, ANNOUNCEMENT, COVID19, PRODUCT.
input.postSitesarray of strings必填Sites to publish to: `GOOGLE`, `FACEBOOK`.
input.postContextInfoobject可选Event details: `{ title, startDay, startTime, endDay, endTime }`. `title` is required by Google for events; `startDay`/`endDay` are dates, `startTime`/`endTime` are display strings like `10:00am`.
input.postMessagearray of objects可选Per-site body text: `{ site, message }`. One entry per site in `postSites`.
input.postScheduledDatesobject可选When to publish/expire the post itself: `{ startDatetime, endDatetime, removalSites }`. Distinct from the event's own dates in `postContextInfo`.
input.postCtaarray of objects可选Optional call-to-action 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": "Summer Sale Kickoff Event",    "locationIds": ["TG9jYXRpb246MTgwMDI4OQ=="],    "postType": "EVENT",    "postSites": ["GOOGLE"],    "postContextInfo": {      "title": "Summer Sale Kickoff",      "startDay": "2026-07-15",      "startTime": "10:00am",      "endDay": "2026-07-15",      "endTime": "06:00pm"    },    "postMessage": [      { "site": "GOOGLE", "message": "Join us for the Summer Sale kickoff, refreshments, giveaways, and up to 40% off in store." }    ],    "postCta": [      { "site": "GOOGLE", "type": "LEARN_MORE", "url": "https://jennyhome.example/summer-event" }    ],    "postMediaUrl": [      { "site": "GOOGLE", "url": "https://cdn.example.com/summer-event.jpg", "type": "IMAGE" }    ]  }}

响应

200Post accepted. Publishing runs asynchronously, the returned post starts as INPROGRESS.
Response
{  "data": {    "createSocialPost": {      "clientMutationId": null,      "success": true,      "errors": [],      "socialPost": {        "id": "U29jaWFsUG9zdDo0NDEyMw==",        "name": "Summer Sale Kickoff Event",        "status": "INPROGRESS",        "type": "EVENT",        "createdAt": "2026-07-01",        "scheduledStartDate": "2026-07-15",        "scheduledEndDate": "2026-07-15",        "sites": ["GOOGLE"],        "message": [          { "site": "GOOGLE", "message": "Join us for the Summer Sale kickoff, refreshments, giveaways, and up to 40% off in store." }        ],        "cta": [          { "type": { "value": "LEARN_MORE", "label": "Learn more" }, "url": "https://jennyhome.example/summer-event", "site": "GOOGLE", "tinyUrl": null }        ],        "contextInfo": {          "title": "Summer Sale Kickoff",          "startDay": "2026-07-15",          "startTime": "10:00am",          "endDay": "2026-07-15",          "endTime": "06:00pm",          "couponCode": null,          "redeemUrl": null,          "termsConditions": null,          "discount": null,          "locationType": null        },        "mediaUrl": [          { "url": "https://cdn.example.com/summer-event.jpg", "site": "GOOGLE", "type": "IMAGE" }        ],        "publishDetails": [          { "site": "GOOGLE", "status": "PUBLISHING", "createdDate": "2026-07-01", "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.

创建活动帖子:这是一则带有日期的公告,包含 title 和开始/结束时间范围,在 Google 上显示为活动卡片。活动本身的日程在 postContextInfo(title、startDay、startTime、endDay、endTime)中设置;可选的 postScheduledDates 控制帖子本身的发布和下架时间,这段时间通常是活动开始前的预热期。

使用场景:推广店内活动。 为 Jenny Home 发布“夏季促销启动”活动公告,将活动时间设为 7 月 15 日,并添加指向活动页面的 LEARN_MORE CTA。设置 postType: "EVENT" 并填写 postContextInfo.title,Google 会拒绝没有标题的活动。调用返回 status: INPROGRESS;通过 GET /posts/{postId} 确认其状态变为 SUCCESS。

注意事项。

  • 请求体必须封装在 input 对象中:每个字段都是 input 的属性。未封装的扁平请求体会被拒绝,并返回 HTTP 400(Variable "$input" of required type "CreateSocialPostMutationInput!" was not provided)。
  • postContextInfo 包含活动日期;postScheduledDates 包含发布日期。使用 postScheduledDates.startDatetime/endDatetime 提前安排帖子的发布时间,并使其在活动结束后自动过期。
  • 为 postSites 中的每个站点提供一个 postMessage 条目。
  • 对于不含日期的普通消息,请使用 公告;对于优惠券/折扣,请使用 优惠。

写入操作:未在实际账户中执行。所示请求和响应根据 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": "Summer Sale Kickoff Event",      "locationIds": [        "TG9jYXRpb246MTgwMDI4OQ=="      ],      "postType": "EVENT",      "postSites": [        "GOOGLE"      ],      "postContextInfo": {        "title": "Summer Sale Kickoff",        "startDay": "2026-07-15",        "startTime": "10:00am",        "endDay": "2026-07-15",        "endTime": "06:00pm"      },      "postMessage": [        {          "site": "GOOGLE",          "message": "Join us for the Summer Sale kickoff, refreshments, giveaways, and up to 40% off in store."        }      ],      "postCta": [        {          "site": "GOOGLE",          "type": "LEARN_MORE",          "url": "https://jennyhome.example/summer-event"        }      ],      "postMediaUrl": [        {          "site": "GOOGLE",          "url": "https://cdn.example.com/summer-event.jpg",          "type": "IMAGE"        }      ]    }  }'