POST/api/v4/posts

Crea un post con un'offerta

Crea un post social OFFER con un coupon, uno sconto e le condizioni, pubblicato sui siti scelti per una o più sedi.

Richiede una chiave API. Consulta Autenticazione per il formato dell’header e la rotazione delle chiavi.

Parametri

Corpo

NomeTipoObbligatorioDescrizione
inputobjectobbligatorioWrapper object. Every field below is a property of `input`, the entire body must be nested under it.
input.postNamestringobbligatorioInternal name for the campaign (not shown to customers).
input.locationIdsarray of stringsobbligatorioBase64-encoded location IDs to publish to (e.g. `TG9jYXRpb246MTgwMDI4OQ==`).
input.postTypestringobbligatorioMust be `OFFER`. One of EVENT, OFFER, ANNOUNCEMENT, COVID19, PRODUCT.
input.postSitesarray of stringsobbligatorioSites to publish to: `GOOGLE`, `FACEBOOK`.
input.postContextInfoobjectfacoltativoOffer details: `{ title, couponCode, discount, redeemUrl, termsConditions, startDay, endDay }`. `title` labels the offer; `startDay`/`endDay` bound its validity.
input.postMessagearray of objectsfacoltativoPer-site body text: `{ site, message }`. One entry per site in `postSites`.
input.postScheduledDatesobjectfacoltativoWhen to publish/expire the post itself: `{ startDatetime, endDatetime, removalSites }`. Distinct from the offer validity in `postContextInfo`.
input.postCtaarray of objectsfacoltativoOptional 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.postMediaUrlarray of objectsfacoltativoOptional media per site: `{ site, url, type }` where `type` is IMAGE or VIDEO.
input.clientMutationIdstringfacoltativoOptional client token returned unchanged in the response for correlation.

Richiesta di esempio

Corpo pronto da incollare. Sostituisci gli ID e i valori segnaposto con i tuoi.

Request body
{  "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" }    ]  }}

Risposte

200Post accepted. Publishing runs asynchronously, the returned post starts as INPROGRESS.
Response
{  "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 un post con un'offerta: una scheda promozionale con un codice coupon, uno sconto, un link per usufruire dell'offerta e le condizioni. I dettagli dell'offerta sono in postContextInfo (title, couponCode, discount, redeemUrl, termsConditions, startDay, endDay). Le offerte si abbinano naturalmente a una CTA GET_OFFER.

Caso d'uso: avvia una promozione a tempo limitato. Lancia un'offerta "Diwali 25% di sconto" per Jenny Home, valida dal 22 giugno al 6 luglio, con il coupon DIWALI25 e un URL per usufruire dell'offerta. Imposta postType: "OFFER", compila postContextInfo e aggiungi una CTA GET_OFFER. La chiamata restituisce status: INPROGRESS; verifica che il post venga pubblicato su ciascun sito con GET /posts/{postId} ed eliminalo in anticipo con DELETE /posts/{postId} se la promozione termina.

Note.

  • Il corpo della richiesta deve essere racchiuso in un oggetto input: ogni campo è una proprietà di input. Un corpo piatto, non racchiuso nell'oggetto, viene rifiutato con uno stato HTTP 400 (Variable "$input" of required type "CreateSocialPostMutationInput!" was not provided).
  • postContextInfo.startDay/endDay delimitano la validità dell'offerta; usa postScheduledDates se vuoi anche programmare in modo indipendente quando il post viene pubblicato/scade.
  • Fornisci una voce postMessage per ciascun sito in postSites.
  • Per semplici aggiornamenti usa gli annunci; per avvenimenti con una data definita usa gli eventi.

Operazione di scrittura: non eseguita sull'account reale. La richiesta e la risposta mostrate sono costruite a partire dallo schema dell'API; quando viene eseguita, questa operazione pubblica su profili Google/Facebook reali.

Request
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"        }      ]    }  }'