> [!IMPORTANT]
> **Important:** For now this add-on is in pilot phase. You need to be approved by Google or already have an existing RTU integration (by having a Dining E2E integration). Get in touch with your Google POC to be granted access. If you are not approved, you will get a quota error message.

Real time updates allow you to keep your offer inventory in sync with Google. You can push incremental updates in near real-time. Our system will compile the changes from Feed + RTU to display the most recent information to users.

## API Endpoints

To push or delete real-time updates, use the following REST API endpoints:

### Batch Push

- Sandbox: `https://partnerdev-mapsbooking.googleapis.com/v1alpha/inventory/partners/{partner_id}/feeds/google.offer/record:batchPush`
- Production: `https://mapsbooking.googleapis.com/v1alpha/inventory/partners/{partner_id}/feeds/google.offer/record:batchPush`

### Batch Delete

- Sandbox: `https://partnerdev-mapsbooking.googleapis.com/v1alpha/inventory/partners/{partner_id}/feeds/google.offer/record:batchDelete`
- Production: `https://mapsbooking.googleapis.com/v1alpha/inventory/partners/{partner_id}/feeds/google.offer/record:batchDelete`

For more information on the Offer JSON object definition, see [Offer](https://developers.google.com/maps-booking/reference/maps-booking-api/rest/v1alpha/Offer.md.txt).
For more details on offer properties, visit the [Offer reference page](https://developers.google.com/maps-booking/reference/maps-booking-api/rpc/madden.ingestion/offer.md.txt).

## How to authenticate to the API

To connect to the API, refer to [Authenticate with Mapsbooking API](https://developers.google.com/actions-center/verticals/offers/reference/tutorials/authenticate-with-mapsbooking-api.md.txt).

## Limitations

When using the real-time updates API, keep the following limitations in mind:

- **protoRecord Only** : The API is configured to only use `protoRecord` (not `dataRecord`).
- **Quota Limits** : These APIs have a quota of **1500 requests per minute per partner account** . Each request is capped to sending **1000 records** for upsert or deletion.
- **Entity Mapping Restrictions** : For each offer, partners can send an update for 1 entity ID. If you want to update the same offer on multiple entity IDs, the partner must send **1 record per `entityId`** . `entityId`s must always be singular per record.
- **Add-on Offers** : Because of the entity mapping restriction, add-on offers that are `addOnOfferApplicableToAllEntities` are not really supported for RTU update and cannot be updated this way (only via feeds).

## Example

> [!NOTE]
> **Note:** This example requires some gcloud CLI authentication setup. This is quite complicated and would only be helpful for testing. If you want to use it anyway, refer to the [gcloud documentation](https://docs.cloud.google.com/docs/authentication/use-service-account-impersonation). These examples are more provided asa an example of how the endpoint and payload should be formatted. For authentication code in different languages we recommend checking [Code samples](https://developers.google.com/actions-center/verticals/offers/reference/real-time-updates-rest/code-samples.md.txt).

### Batch Updates Example

Here is an example of pushing a real-time update via `curl`:

```bash
curl -X POST \
  -H "Authorization: Bearer $(gcloud auth application-default print-access-token --impersonate-service-account=test@myproject.gserviceaccount.com --scopes=https://www.googleapis.com/auth/mapsbooking)" \
  -H "Content-Type: application/json" \
  -d '{
  "records": [
    {
      "generationTimestamp": {
        "seconds": 100
      },
      "protoRecord": {
        "@type": "type.googleapis.com/madden.ingestion.offer.Offer",
        "offerId": "1",
        "entityIds": [
          "1234567890"
        ],
        "addOnOfferApplicableToAllEntities": false,
        "offerSource": "OFFER_SOURCE_AGGREGATOR",
        "actionType": "ACTION_TYPE_FOOD_DELIVERY",
        "offerModes": [
          "OFFER_MODE_ONLINE_ORDER"
        ],
        "offerCategory": "OFFER_CATEGORY_BASE_OFFER",
        "tags": [
          "OFFER_TAG_NEW_YEAR_SPECIAL"
        ],
        "offerDetails": {
          "offerDisplayText": "FLAT 10% off on starters",
          "offerSummaryText": "MONDAY TO FRIDAY",
          "otherOfferDetailText": "FLAT 10% off on starters"
        },
        "offerRestrictions": {
          "combinableWithOtherOffers": true,
          "inclusions": [
            {
              "description": "starters"
            }
          ],
          "exclusions": [
            {
              "description": "taxes and Tips"
            }
          ]
        },
        "validityPeriods": [
          {
            "timeOfDay": {
              "timeWindows": [
                {
                  "openTime": {
                    "hours": 10
                  },
                  "closeTime": {
                    "hours": 20
                  }
                }
              ]
            },
            "validPeriod": {
              "validFromTime": {
                "seconds": 10
              }
            }
          }
        ],
        "offerUrl": "https://www.google.com/offer"
      }
    }
  ]
}' \
  https://partnerdev-mapsbooking.googleapis.com/v1alpha/inventory/partners/20000123/feeds/google.offer/record:batchPush
```

### Batch Delete Example

Here is an example of deleting an offer via `curl`:

```bash
curl -X POST \
  -H "Authorization: Bearer $(gcloud auth application-default print-access-token --impersonate-service-account=test@myproject.gserviceaccount.com --scopes=https://www.googleapis.com/auth/mapsbooking)" \
  -H "Content-Type: application/json" \
  -d '{
  "records": [
    {
      "deleteTime": {
        "seconds": 150
      },
      "protoRecord": {
        "@type": "type.googleapis.com/madden.ingestion.offer.Offer",
        "offerId": "1",
        "entityIds": [
          "1234567890"
        ]
      }
    }
  ]
}' \
  https://partnerdev-mapsbooking.googleapis.com/v1alpha/inventory/partners/20000123/feeds/google.offer/record:batchDelete
```