POST/api/v4/posts

Criar uma publicação de oferta

Cria uma publicação social OFFER com cupom, desconto e termos, publicada nos sites escolhidos para um ou mais locais.

Requer uma chave de API. Consulte Autenticação para ver o formato do cabeçalho e a rotação de chaves.

Parâmetros

Corpo

NomeTipoObrigatórioDescrição
inputobjectobrigatórioWrapper object. Every field below is a property of `input`, the entire body must be nested under it.
input.postNamestringobrigatórioInternal name for the campaign (not shown to customers).
input.locationIdsarray of stringsobrigatórioBase64-encoded location IDs to publish to (e.g. `TG9jYXRpb246MTgwMDI4OQ==`).
input.postTypestringobrigatórioMust be `OFFER`. One of EVENT, OFFER, ANNOUNCEMENT, COVID19, PRODUCT.
input.postSitesarray of stringsobrigatórioSites to publish to: `GOOGLE`, `FACEBOOK`.
input.postContextInfoobjectopcionalOffer details: `{ title, couponCode, discount, redeemUrl, termsConditions, startDay, endDay }`. `title` labels the offer; `startDay`/`endDay` bound its validity.
input.postMessagearray of objectsopcionalPer-site body text: `{ site, message }`. One entry per site in `postSites`.
input.postScheduledDatesobjectopcionalWhen to publish/expire the post itself: `{ startDatetime, endDatetime, removalSites }`. Distinct from the offer validity in `postContextInfo`.
input.postCtaarray of objectsopcionalOptional 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 objectsopcionalOptional media per site: `{ site, url, type }` where `type` is IMAGE or VIDEO.
input.clientMutationIdstringopcionalOptional client token returned unchanged in the response for correlation.

Exemplo de requisição

Corpo pronto para colar. Substitua os IDs e valores de exemplo pelos seus.

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

Respostas

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.

Cria uma publicação de oferta: um cartão promocional com código de cupom, desconto, link de resgate e termos. Os detalhes da oferta estão em postContextInfo (title, couponCode, discount, redeemUrl, termsConditions, startDay, endDay). As ofertas combinam naturalmente com uma CTA GET_OFFER.

Caso de uso: realizar uma promoção por tempo limitado. Lance uma oferta "Diwali com 25% de desconto" para Jenny Home, válida de 22 de junho a 6 de julho, com o cupom DIWALI25 e uma URL de resgate. Defina postType: "OFFER", preencha postContextInfo e adicione uma CTA GET_OFFER. A chamada retorna status: INPROGRESS; verifique se a publicação aparece em cada site com GET /posts/{postId} e exclua-a antecipadamente com DELETE /posts/{postId} se a promoção terminar.

Observações.

  • O corpo da requisição deve estar encapsulado em um objeto input: cada campo é uma propriedade de input. Um corpo plano, sem encapsulamento, é rejeitado com o status HTTP 400 (Variable "$input" of required type "CreateSocialPostMutationInput!" was not provided).
  • postContextInfo.startDay/endDay delimitam a validade da oferta; use postScheduledDates se você também quiser agendar de forma independente quando a publicação será publicada ou expirará.
  • Forneça uma entrada postMessage para cada site em postSites.
  • Para atualizações simples, use anúncios; para acontecimentos com data definida, use eventos.

Operação de escrita: não executada na conta real. A requisição e a resposta exibidas são construídas a partir do esquema da API; quando executada, esta operação publica em perfis reais do 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": "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"        }      ]    }  }'