## Create and upload service feeds

When creating and uploading service feeds, follow these instructions:

- Follow the spec described in the [service feed](https://developers.google.com/actions-center/verticals/ordering/redirect/reference/feeds/services-feed#FoodServiceFeed-definition) for service data files. We recommend using unique service data file names for each upload. Include a timestamp in the filename, for example, `service_1633621547.json`.
- In the fileset descriptor, set the `name` field to `google.food_service`. For an example of the descriptor file, refer to the [JSON sample](https://developers.google.com/actions-center/verticals/ordering/redirect/reference/feeds/services-feed#descriptor-file). We recommend using unique descriptor file names for each upload. Include a timestamp in the filename, for example, `service_1633621547.filesetdesc.json`. The descriptor file must be uploaded to the generic SFTP server.
- Upload feeds to the generic SFTP server daily as full refreshes.
- You can find SFTP server details in the [Configuration \> Feeds](https://partnerdash.google.com/apps/reservewithgoogle/configuration/feeds) section of the Partner Portal.

![Selecting feed servers](https://developers.google.com/static/actions-center/images/menus-integration-generic-feeds.png)
Selecting feed servers in the Partner Portal
- View feed ingestion status in the [Ingestion \> History](https://partnerdash.google.com/apps/reservewithgoogle/dashboards/feeds) section of the Partner Portal.

## Definitions

> [!NOTE]
> **Note:** The services feed spec is defined in protobuffer format below, however we recommend you to upload the feeds in JSON format. For more information,refer [JSON sample feeds](https://developers.google.com/actions-center/verticals/ordering/redirect/reference/feeds/services-feed#samples).

### FoodServiceFeed definition

```protobuf
// Food Ordering Team's EPA Service Feeds Spec.
message FoodServiceFeed {
  // Service feed entity data.
  repeated ServiceData data = 1;
}
```

### ServiceData definition

```protobuf
// Service feed entity data.
message ServiceData {
  oneof type {
    FoodOrderingService service = 1;
    ServiceHours service_hours = 2;
    ServiceArea service_area = 3;
    Fee fee = 4;
  }
}
```

### Ordering Redirect Service definition

```protobuf
message FoodOrderingService {
  // Unique identifier of the provided service.
  // Required.
  string service_id = 1;

  enum ServiceType {
    SERVICE_TYPE_UNKNOWN = 0;
    DELIVERY = 1;
    TAKEOUT = 2;
  }

  // The type of the service.
  // Required and cannot be SERVICE_TYPE_UNKNOWN.
  ServiceType service_type = 2;

  // The parent entity's ID.
  // Required.
  string parent_entity_id = 3;

  // Indicates if the entity is disabled.
  // Optional.
  bool disabled = 4;

  // The lead time given in the service entity will apply to all
  // the service hours unless an overridden property is set in the
  // service hours entity.
  // Required.
  ETA lead_time = 5;

  // Parent action detail's link ID.
  // Required.
  string action_link_id = 6;
}
// (--
// --)
```

### ETA definition

```protobuf
// Lead time range [min, max). At least one of min or max needs to be provided.
// A fixed value can be provided by setting both min and max to the same value.
message ETA {
  // Indicates a range of ETA duration.
  google.protobuf.Duration min_lead_time_duration = 1;
  google.protobuf.Duration max_lead_time_duration = 2;
}
// (--
```

### [Fees definition](https://developers.google.com/actions-center/verticals/ordering/redirect/reference/feeds/fees)

```protobuf
message Fee {
  // Unique identifier to the Fee entity.
  // Required.
  string fee_id = 1;

  enum FeeType {
    FEE_TYPE_UNKNOWN = 0;
    DELIVERY = 1;
    SERVICE = 2;
  }

  // Indicates the nature of the service, e.g. delivery fee/service fee.
  // Required.
  FeeType fee_type = 2;

  oneof amount {

    // A fixed amount of fees to be collected.
    google.type.Money fixed_amount = 3;

    // A range of fees that could be collected. Will mirror
    // madden.ingestion.MoneyRange for the starting point.
    MoneyRange range_amount = 4;

    // Fees in terms of amount percentage. Will mirror
    // madden.ingestion.QuantitativeValue for the starter.
    PercentageBasedFee cart_percentage = 5;
  }

  // Service association needs to be provided.
  // Required.
  repeated string service_ids = 6;

  // Service area can be provided to further restrict eligibility of the
  // fee.
  // Optional.
  repeated string area_ids = 7;
}
// (--
// --)
```

### MoneyRange definition

```protobuf
// Wrapper for a range of monetary amount that could be bounded or unbounded.
// At least one of min_amount or max_amount is required.
message MoneyRange {
  // Minimum amount.
  google.type.Money min_amount = 1;

  // Maximum amount.
  google.type.Money max_amount = 2;
}
```

### PercentageBasedFee definition

```protobuf
// Variable fee which changes based on the price of the order.
message PercentageBasedFee {
  // Optional, base fee not including the variable percentage based fee.
  google.type.Money base_value = 1;

  // Optional, overall range of possible values of the PercentageBasedFee.
  MoneyRange range = 2;

  // Optional, percentage representing an additional variable fee based on
  // the cart subtotal. E.g. 15.0 represents a fee of 15% of the cart.
  double percentage_of_cart_value       3;
}
```

### ServiceArea definition

```protobuf
message ServiceArea {
  // Unique identifier.
  // Required.
  string area_id = 1;
  // Identifier to the parent service entity.
  // Required.
  repeated string service_ids = 2;
  // One of the following needs to be provided to define the service area.
  // Required.
  oneof region {

    GeoCircle circle = 3;
    Locality locality = 4;
    Polygon polygon = 5;
  }

  // Sets to true if the assigned area is excluded from serving.
  // Optional.
  optional bool excluded_area = 6;
}
// (--
```

### GeoCircle definition

```protobuf
// Geographical circular area described by a point and radius.
message GeoCircle {
  // Geographical center of the area.
  // Required.
  google.type.LatLng center       1;

  // Radius for the circular area, in meters. Must be greater than 0.
  // Required.
  double radius = 2;
}
```

### Locality definition

```protobuf
// Geolocation of interests.
message Locality {
  string country_code = 1;

  // Postal code in the country's local format in string.
  string postal_code       2;
}
```

### Polygon definition

```protobuf
// Represents a polygon shaped region.
message Polygon {
  reserved 1;

  // List of S2Loops which defines a polygon. A point is considered in the
  // polygon if it is contained in odd number of loops.
  repeated Loop loops = 2;
}
```

### Loop definition

```protobuf
// Represents a loop of geo coordinates. This should be a valid S2Loop.
message Loop {
  // Points making the boundary of loop.
  repeated google.type.LatLng point       1;
}
```

### ServiceHours definition

```protobuf
// Service hours entity for ASAP/Advance orders.
message ServiceHours {
  // Unique identifier of the provided advance service hours.
  // Required.
  string hours_id       1;

  // The unique identifier of the Service entity correlated to this ServiceHours
  // entity.
  // Required.
  repeated string service_ids = 2;
  // The hours the orders can be fulfilled. For ASAP services, this is also
  // orderable time.
  // One of the fields (asap_hours/advance_hours) is required to be set.
  repeated AsapTimeWindow asap_hours = 3;
  repeated AdvanceTimeWindow advance_hours = 4;

  // When advance ordering services, this is the time windows the orders can be
  // placed.
  // Required when advance_hour is given. Invalid when asap_hour is given.
  repeated TimeOfDayWindow orderable_time = 5;

  // Indicates if the service hours are for special occasions
  // (e.g. Thanksgiving/...)
  // Optional
  bool special_hour = 6;
  // A timestamp window indicating the validity of the special hours.
  // Optional. Required if it's special hours.
  ValidityRange validity_range = 7;
}
// (--
```

### AsapTimeWindow definition

```protobuf
message AsapTimeWindow {
  // A time window the ASAP order can be placed and fulfilled.
  // Required.
  TimeOfDayWindow time_windows = 1;

  // Indicates the lead time, specific to service_time, the service can
  // be fulfilled.
  // Optional.
  ETA lead_time = 2;
}
```

### AdvanceTimeWindow definition

```protobuf
// The fulfillment time window for advance orders.
message AdvanceTimeWindow {
  // A time window the advance order can be fulfilled.
  // Required.
  TimeOfDayWindow time_windows = 1;
  // a window that an advance order can be placed.  For example, an advance
  // order must be placed at least 60 minutes ahead and not exceeding 2
  // days, the interval would be [PT60M, P2D).
  // Optional.
  DurationInterval advance_booking_interval = 2;
}
```

### TimeOfDayWindow definition

```protobuf
// The TimeWindow object is a composite entity that describes a list
// of windows the user's order can be either placed or fulfilled.
message TimeOfDayWindow {
  // The time window the order can be placed/fulfilled.
  // Required.
  TimeOfDayRange time_windows = 1;
  // The list of days in a week the windows are applied.
  // Required. If not given, we assume 7 days a week.
  repeated google.type.DayOfWeek day_of_week = 2;
}
```

### ValidityRange definition

```protobuf
// A closed-open timestamp range.
message ValidityRange {
  // The beginning time of the range (inclusive).
  // Optional.
  google.protobuf.Timestamp valid_from_time = 1;
  // The ending time of the range (exclusive).
  // Optional.
  google.protobuf.Timestamp valid_through_time = 2;
}
```

### DurationInterval definition

```protobuf
// A closed-open duration range.
message DurationInterval {
  // The minimum duration (inclusive).
  // Required.
  google.protobuf.Duration min_offset = 1;
  // The maximum duration (exclusive).
  // Required.
  google.protobuf.Duration max_offset = 2;
}
```

### TimeOfDayRange definition

```protobuf
// A closed-open time range.
message TimeOfDayRange {
  // A Time indicating the beginning time of the day of the range (inclusive).
  // Required. If not given, we assume 00:00:00.
  google.type.TimeOfDay open_time = 1;
  // A Time indicating the ending time of the day of the range (exclusive).
  // Required. If not given, we assume 23:59:59.
  google.type.TimeOfDay close_time = 2;
}
```


External proto references:

- [google.type.Money.proto](https://github.com/googleapis/googleapis/blob/master/google/type/money.proto)
- [google.type.latlng.proto](https://github.com/googleapis/googleapis/blob/master/google/type/latlng.proto)
- [google.type.dayofweek.proto](https://github.com/googleapis/googleapis/blob/master/google/type/dayofweek.proto)
- [google.type.timeofday.proto](https://github.com/googleapis/googleapis/blob/master/google/type/timeofday.proto)
- [google.protobuf.duration.proto](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/duration.proto)
- [google.protobuf.timestamp.proto](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/timestamp.proto)

<br />

## Service feed samples

<br />

### Services feed

#### Filename : services_1697754089_0001.json

```json
{
  "data": [
    {
      "service": {
        "service_id": "delivery-dining-1-service",
        "service_type": "DELIVERY",
        "parent_entity_id": "dining-1",
        "lead_time": {
          "min_lead_time_duration": "1200s",
          "max_lead_time_duration": "1800s"
        },
        "action_link_id": "delivery-dining-1"
      }
    },
    {
      "fee": {
        "fee_id": "delivery-dining-1-fee",
        "fee_type": "DELIVERY",
        "fixed_amount": {
          "currency_code": "USD",
          "units": 2,
          "nanos": 400000000
        },
        "service_ids": ["delivery-dining-1-service"]
      }
    },
    {
      "fee": {
        "fee_id": "delivery-dining-1-service_fee",
        "fee_type": "SERVICE",
        "fixed_amount": {
          "currency_code": "USD",
          "units": 0,
          "nanos": 0
        },
        "service_ids": ["delivery-dining-1-service"]
      }
    },
    {
      "service": {
        "service_id": "takeout-dining-1-service",
        "service_type": "TAKEOUT",
        "parent_entity_id": "dining-1",
        "lead_time": {
          "min_lead_time_duration": "600s",
          "max_lead_time_duration": "1800s"
        },
        "action_link_id": "takeout-dining-1"
      }
    },
    {
      "fee": {
        "fee_id": "takeout-dining-1-service_fee",
        "fee_type": "SERVICE",
        "fixed_amount": {
          "currency_code": "USD",
          "units": 0,
          "nanos": 0
        },
        "service_ids": ["takeout-dining-1-service"]
      }
    }
  ]
}
```

### Descriptor file

#### Filename : services_1697754089.filesetdesc.json

```json
{
  "generation_timestamp": 1697754089,
  "name": "google.food_service",
  "data_file": [
    "services_1697754089_0001.json",
    "services_1697754089_0002.json"
  ]
}
```