/api/v4/postsCrear una publicación de oferta
Crea una publicación social de tipo OFFER con un cupón, un descuento y condiciones, que se publica en los sitios elegidos para una o más ubicaciones.
Parámetros
Cuerpo
| Nombre | Tipo | Obligatorio | Descripción |
|---|---|---|---|
| input | object | obligatorio | Wrapper object. Every field below is a property of `input`, the entire body must be nested under it. |
| input.postName | string | obligatorio | Internal name for the campaign (not shown to customers). |
| input.locationIds | array of strings | obligatorio | Base64-encoded location IDs to publish to (e.g. `TG9jYXRpb246MTgwMDI4OQ==`). |
| input.postType | string | obligatorio | Must be `OFFER`. One of EVENT, OFFER, ANNOUNCEMENT, COVID19, PRODUCT. |
| input.postSites | array of strings | obligatorio | Sites to publish to: `GOOGLE`, `FACEBOOK`. |
| input.postContextInfo | object | opcional | Offer details: `{ title, couponCode, discount, redeemUrl, termsConditions, startDay, endDay }`. `title` labels the offer; `startDay`/`endDay` bound its validity. |
| input.postMessage | array of objects | opcional | Per-site body text: `{ site, message }`. One entry per site in `postSites`. |
| input.postScheduledDates | object | opcional | When to publish/expire the post itself: `{ startDatetime, endDatetime, removalSites }`. Distinct from the offer validity in `postContextInfo`. |
| input.postCta | array of objects | opcional | Optional call-to-action per site: `{ site, type, url }`. The `CTAType` enum accepts BOOK, ORDER, SHOP, LEARN_MORE, SIGN_UP, and GET_OFFER. There is no `REDEEM`. For offer posts, Google takes ORDER and Facebook takes GET_OFFER. |
| input.postMediaUrl | array of objects | opcional | Optional media per site: `{ site, url, type }` where `type` is IMAGE or VIDEO. |
| input.clientMutationId | string | opcional | Optional client token returned unchanged in the response for correlation. |
Solicitud de ejemplo
Cuerpo listo para pegar. Sustituye los ID y valores de ejemplo por los tuyos.
{ "input": { "postName": "Diwali 25% Off", "locationIds": ["TG9jYXRpb246MTgwMDI4OQ=="], "postType": "OFFER", "postSites": ["GOOGLE"], "postContextInfo": { "title": "25% off storewide", "couponCode": "DIWALI25", "discount": "25%", "redeemUrl": "https://jennyhome.example/diwali", "termsConditions": "Valid in-store only through July 6. Cannot be combined with other offers.", "startDay": "2026-06-22", "endDay": "2026-07-06" }, "postMessage": [ { "site": "GOOGLE", "message": "Celebrate with us: 25% off everything in store this festive week." } ], "postCta": [ { "site": "GOOGLE", "type": "GET_OFFER", "url": "https://jennyhome.example/diwali" } ], "postMediaUrl": [ { "site": "GOOGLE", "url": "https://cdn.example.com/diwali.jpg", "type": "IMAGE" } ] }}Respuestas
200Post accepted. Publishing runs asynchronously, the returned post starts as INPROGRESS.
{ "data": { "createSocialPost": { "clientMutationId": null, "success": true, "errors": [], "socialPost": { "id": "U29jaWFsUG9zdDo0NDEyNA==", "name": "Diwali 25% Off", "status": "INPROGRESS", "type": "OFFER", "createdAt": "2026-06-20", "scheduledStartDate": "2026-06-22", "scheduledEndDate": "2026-07-06", "sites": ["GOOGLE"], "message": [ { "site": "GOOGLE", "message": "Celebrate with us: 25% off everything in store this festive week." } ], "cta": [ { "type": { "value": "GET_OFFER", "label": "Get offer" }, "url": "https://jennyhome.example/diwali", "site": "GOOGLE", "tinyUrl": null } ], "contextInfo": { "title": "25% off storewide", "couponCode": "DIWALI25", "discount": "25%", "redeemUrl": "https://jennyhome.example/diwali", "termsConditions": "Valid in-store only through July 6. Cannot be combined with other offers.", "startDay": "2026-06-22", "endDay": "2026-07-06", "startTime": null, "endTime": null, "locationType": null }, "mediaUrl": [ { "url": "https://cdn.example.com/diwali.jpg", "site": "GOOGLE", "type": "IMAGE" } ], "publishDetails": [ { "site": "GOOGLE", "status": "PUBLISHING", "createdDate": "2026-06-20", "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.
Crea una publicación de oferta: una tarjeta promocional con un código de cupón, un descuento, un enlace para canjear la oferta y condiciones. Los detalles de la oferta se encuentran en postContextInfo (title, couponCode, discount, redeemUrl, termsConditions, startDay, endDay). Las ofertas encajan de forma natural con una llamada a la acción de tipo GET_OFFER.
Caso de uso: realizar una promoción por tiempo limitado. Lanza una oferta de "25% de descuento por Diwali" para Jenny Home, válida del 22 de junio al 6 de julio, con el cupón DIWALI25 y una URL para canjearla. Configura postType: "OFFER", completa postContextInfo y añade una llamada a la acción de tipo GET_OFFER. La llamada devuelve status: INPROGRESS; verifica que la oferta se publique en cada sitio con GET /posts/{postId} y elimínala antes de tiempo con DELETE /posts/{postId} si la promoción termina.
Notas.
- El cuerpo de la solicitud debe estar dentro de un objeto
input: cada campo es una propiedad deinput. Un cuerpo plano, sin ese objeto contenedor, se rechaza con un estado HTTP 400 (Variable "$input" of required type "CreateSocialPostMutationInput!" was not provided). postContextInfo.startDay/endDaydelimitan la vigencia de la oferta; usapostScheduledDatessi también quieres programar de forma independiente cuándo se publica y cuándo caduca la publicación.- Proporciona una entrada de
postMessagepara cada sitio depostSites. - Para actualizaciones sencillas, usa anuncios; para acontecimientos con fecha, usa eventos.
Operación de escritura: no se ha ejecutado en la cuenta real. La solicitud y la respuesta mostradas se generan a partir del esquema de la API; al ejecutarse, esta operación publica en perfiles reales de Google/Facebook.
curl -X POST 'https://listingsapi.com/api/v4/posts' \ -H "Authorization: API $LISTINGSAPI_KEY" \ -H 'Content-Type: application/json' \ -d '{ "input": { "postName": "Diwali 25% Off", "locationIds": [ "TG9jYXRpb246MTgwMDI4OQ==" ], "postType": "OFFER", "postSites": [ "GOOGLE" ], "postContextInfo": { "title": "25% off storewide", "couponCode": "DIWALI25", "discount": "25%", "redeemUrl": "https://jennyhome.example/diwali", "termsConditions": "Valid in-store only through July 6. Cannot be combined with other offers.", "startDay": "2026-06-22", "endDay": "2026-07-06" }, "postMessage": [ { "site": "GOOGLE", "message": "Celebrate with us: 25% off everything in store this festive week." } ], "postCta": [ { "site": "GOOGLE", "type": "GET_OFFER", "url": "https://jennyhome.example/diwali" } ], "postMediaUrl": [ { "site": "GOOGLE", "url": "https://cdn.example.com/diwali.jpg", "type": "IMAGE" } ] } }'