Create Posts on Google

The Google My Business API provides you with the ability to create Posts in Google Search within several categories, such as news, events, and offers.

This tutorial shows you how to do the following:

Before you begin

Before you use the Google My Business API, you need to register your application and obtain OAuth 2.0 credentials.

For details on how to get started with the Google My Business API, see Basic setup.

Event Posts

Notify your customers about the next event at your business with a Post. Your Post for an event includes start and end dates and times, which display prominently on the Post.

To make a Post to an account associated with a user, use the accounts.locations.localPosts API.

To create a Post for an authenticated user, use the following:

HTTP
$ POST
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/localPosts
{
  "languageCode": "en-US",
  "summary": "Come in for our spooky Halloween event!",
  "event": {
    "title": "Halloween Spook-tacular!",
    "schedule": {
        "startDate": {
            "year": 2017,
            "month": 10,
            "day": 31,
          },
          "startTime": {
              "hours": 9,
              "minutes": 0,
              "seconds": 0,
              "nanos": 0,
          },
          "endDate": {
            "year": 2017,
            "month": 10,
            "day": 31,
          },
          "endTime": {
              "hours": 17,
              "minutes": 0,
              "seconds": 0,
              "nanos": 0,
          },
    }
  },
  "media": [
    {
      "mediaFormat": "PHOTO",
      "sourceUrl": "https://www.google.com/real-image.jpg",
    }
  ],
  "topicType": "EVENT"
}

Call to action Posts

Posts with a call to action include a button. The text on the call to action button is determined by the actionType field of the Post. A link to a user-provided URL is added to the button.

To create a Post with a call to action button, use the following:

HTTP
$ POST
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/localPosts
{
  "languageCode": "en-US",
  "summary": "Order your Thanksgiving turkeys now!!",
  "callToAction": {
    "actionType": "ORDER",
    "url": "http://google.com/order_turkeys_here",
  },
  "media": [
    {
      "mediaFormat": "PHOTO",
      "sourceUrl": "https://www.google.com/real-turkey-photo.jpg",
    }
  ],
  "topicType": "OFFER"
}

Action types

The call to action Posts can have different action types that determine the type of call to action Post.

The following are the supported call to action types:

Action types
BOOK Creates a Post that prompts a user to book an appointment, table, or something similar.
ORDER Creates a Post that prompts a user to order something.
SHOP Creates a Post that prompts a user to browse a product catalog.
LEARN_MORE Creates a Post that prompts a user to see additional details on a website.
SIGN_UP Creates a Post that prompts a user to register, sign up, or join something.
CALL Creates a Post that prompts a user to call a business.

Offer Posts

To create an Offer Post, use the following:

HTTP
$ POST
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/localPosts
{
  "languageCode": "en-US",
  "summary": "Buy one Google jetpack, get a second one free!!",
  "offer": {
       "couponCode": “BOGO-JET-CODE”,
       "redeemOnlineUrl": “https://www.google.com/redeem”,
       "termsConditions": “Offer only valid if you can prove you are a time traveler”
  },
  "media": [
    {
      "mediaFormat": "PHOTO",
      "sourceUrl": "https://www.google.com/real-jetpack-photo.jpg",
    }
  ],
  "topicType": "OFFER"
}

Edit Posts

Once a post is created, you can edit it with a PATCH request.

To edit a Post, use the following:

HTTP
$ PATCH
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/localPosts/{localPostId}?updateMask=summary
{
  "summary": "Order your Christmas turkeys now!!"
}

Delete Posts

After a Post is created, you can delete it with a DELETE request.

To delete a Post, use the following:

HTTP
$ DELETE
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/localPosts/{localPostId}