/api/v4/postsBuat postingan acara
Membuat postingan sosial EVENT dengan judul dan rentang waktu mulai/selesai, yang dipublikasikan ke situs yang dipilih untuk satu atau beberapa lokasi.
Parameter
Body
| Nama | Tipe | Wajib | Deskripsi |
|---|---|---|---|
| input | object | wajib | Wrapper object. Every field below is a property of `input`, the entire body must be nested under it. |
| input.postName | string | wajib | Internal name for the campaign (not shown to customers). |
| input.locationIds | array of strings | wajib | Base64-encoded location IDs to publish to (e.g. `TG9jYXRpb246MTgwMDI4OQ==`). |
| input.postType | string | wajib | Must be `EVENT`. One of EVENT, OFFER, ANNOUNCEMENT, COVID19, PRODUCT. |
| input.postSites | array of strings | wajib | Sites to publish to: `GOOGLE`, `FACEBOOK`. |
| input.postContextInfo | object | opsional | 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.postMessage | array of objects | opsional | Per-site body text: `{ site, message }`. One entry per site in `postSites`. |
| input.postScheduledDates | object | opsional | When to publish/expire the post itself: `{ startDatetime, endDatetime, removalSites }`. Distinct from the event's own dates in `postContextInfo`. |
| input.postCta | array of objects | opsional | Optional call-to-action per site: `{ site, type, url }`. `type` is one of BOOK, ORDER, SHOP, LEARN_MORE, SIGN_UP, GET_OFFER. |
| input.postMediaUrl | array of objects | opsional | Optional media per site: `{ site, url, type }` where `type` is IMAGE or VIDEO. |
| input.clientMutationId | string | opsional | Optional client token returned unchanged in the response for correlation. |
Contoh permintaan
Body siap tempel. Ganti ID dan nilai placeholder dengan milik Anda.
{ "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" } ] }}Respons
200Post accepted. Publishing runs asynchronously, the returned post starts as INPROGRESS.
{ "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.
Membuat postingan acara: pengumuman bertanggal dengan title dan rentang waktu mulai/selesai yang ditampilkan sebagai kartu acara di Google. Jadwal acara itu sendiri ada di postContextInfo (title, startDay, startTime, endDay, endTime); postScheduledDates yang opsional mengatur kapan postingan itu sendiri dipublikasikan dan ditarik, yang biasanya mencakup periode menjelang acara.
Kasus penggunaan: promosikan acara di toko. Umumkan "Pembukaan Promo Musim Panas" untuk Jenny Home dengan rentang waktu acara pada 15 Juli dan CTA LEARN_MORE yang mengarah ke halaman acara. Tetapkan postType: "EVENT" dan isi postContextInfo.title; Google menolak acara tanpa judul. Pemanggilan ini mengembalikan status: INPROGRESS; pastikan melalui GET /posts/{postId} bahwa statusnya mencapai SUCCESS.
Catatan.
- Isi permintaan harus dibungkus dalam objek
input: setiap field merupakan properti dariinput. Isi permintaan datar tanpa pembungkus ditolak dengan HTTP 400 (Variable "$input" of required type "CreateSocialPostMutationInput!" was not provided). postContextInfoberisi tanggal acara;postScheduledDatesberisi tanggal publikasi. GunakanpostScheduledDates.startDatetime/endDatetimeuntuk menjadwalkan postingan terlebih dahulu dan mengakhiri masa berlakunya secara otomatis setelah acara.- Sediakan entri
postMessageuntuk setiap situs dipostSites. - Untuk pesan biasa tanpa tanggal, gunakan pengumuman; untuk kupon/diskon, gunakan penawaran.
Operasi tulis: tidak dijalankan pada akun aktif. Permintaan dan respons yang ditampilkan disusun berdasarkan skema API; operasi ini memublikasikan postingan ke profil Google/Facebook sungguhan saat dijalankan.
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" } ] } }'