Posts & content types
Create a Google Business Profile post with an image, add a call-to-action button, publish text only and edit a published post.
By the end of this page, you have published a post with an image to Google Business Profile (googlebusiness) with POST /v1/posts. You have also added a call-to-action button and edited a published post with POST /v1/posts/{postId}/edit.
Before you start
You need an API key and a connected Google Business Profile account (accountId, from the Google Business Profile page).
Step 1: create a post with an image
Call POST /v1/posts (Create post) with:
content- one image in
mediaItems - a
platformsentry withplatform: "googlebusiness" publishNow: true
With no topicType the post is a STANDARD update.
To schedule instead, replace publishNow with scheduledFor and timezone. The post lifecycle guide covers the statuses.
import Zernio from '@zernio/node';
const zernio = new Zernio();
const { data: published } = await zernio.posts.createPost({
body: {
content: 'Open all holiday weekend. Stop by for the seasonal menu.',
mediaItems: [
{ type: 'image', url: 'https://cdn.example.com/holiday-special.jpg' }
],
platforms: [
{ platform: 'googlebusiness', accountId: '66b2e19d8c3f5a7e9d0b1c2d' }
],
publishNow: true
}
});
console.log(published.post.platforms[0].platformPostUrl);Response (201):
{
"post": {
"_id": "65f1c0a9e2b5af0012ab34cd",
"status": "published",
"platforms": [
{
"platform": "googlebusiness",
"status": "published",
"platformPostId": "1234567890123456789",
"platformPostUrl": "https://business.google.com/..."
}
]
}
}Omit mediaItems for a text-only post. A post carries at most 1 image and no video.
Every sample below changes only the platforms entry of this request and returns the same response.
Step 2: add a call-to-action button
Set platformSpecificData.callToAction with a type and an HTTPS url. The button appears under the post.
{
"platform": "googlebusiness",
"accountId": "66b2e19d8c3f5a7e9d0b1c2d",
"platformSpecificData": {
"callToAction": { "type": "BOOK", "url": "https://mybusiness.com/book" }
}
}type | Button | Typical use |
|---|---|---|
LEARN_MORE | Link to more information | Articles, about pages |
BOOK | Booking or reservation link | Services, appointments |
ORDER | Online ordering link | Restaurants, food |
SHOP | E-commerce link | Retail, products |
SIGN_UP | Registration link | Events, newsletters |
CALL | Phone call | Contact, inquiries |
Event and offer posts add topicType and an event or offer object on top of this. See Event & Offer Posts.
Step 3: edit a published post
Call POST /v1/posts/{postId}/edit with platform: "googlebusiness" and the new content (Edit post).
Only the post body changes. For every post type, these stay as published: the call to action, the event title and schedule, the offer fields and the image. To change the image, publish a new post.
There is no time window and no edit limit, and the post keeps its id.
id in the response is Google's post id, the platformPostId from Step 1. It is not the Zernio _id you pass in the path.
const { data: edited } = await zernio.posts.editPost({
path: { postId: '65f1c0a9e2b5af0012ab34cd' },
body: {
platform: 'googlebusiness',
content: 'Open all holiday weekend, 8am to 8pm. Stop by for the seasonal menu.'
}
});
console.log(edited.id, edited.url);Response (200):
{
"success": true,
"id": "1234567890123456789",
"url": "https://business.google.com/...",
"message": "googlebusiness post edited successfully"
}Two accounts. If the post went to two connected accounts, pass accountId in the body to pick which one to edit.
Several locations. accountId selects the account, not the location. A post fanned out to several locations from one account always edits that account's first entry.
If it fails
A 404 on POST /v1/posts/{postId}/edit means the post no longer exists on Google. Either it was deleted from the Business Profile dashboard, or it is an EVENT or OFFER post whose end date has passed.
{
"error": "Not found",
"type": "not_found"
}Publish a new post instead; the edit cannot be retried.
Error handling covers the envelope, and Fields, Media & Limits lists the publishing errors.
Related
- Event & Offer Posts:
topicType,eventandoffer. - Multi-Location Posting:
locationIdfor accounts with several locations. - Fields, Media & Limits: image requirements and the full field table.
- Post lifecycle: statuses and what you can do in each.
- Idempotency: safe retries with
x-request-id.