# Search Workflows

You can combine the into various workflows, determined by whether you want more upsells, and whether you want the initial Search to return offers for all legs of the itinerary ( a journey-based search) or only the first leg (a leg-based search). A leg-based search must be followed by a Next Leg Search to return offers on the subsequent leg of the itinerary. For a leg-based, multi-city itinerary you would send Next Leg Search again for the third leg, and so on for additional legs (not shown below).

To set whether the search is journey- or leg-based, send SearchRepresentation with the value *Leg* for a leg-based search or *Journey* for a journey-based search. If SearchRepresentation is not sent, the default is a journey-based response. This setting does not apply to one-way searches and is ignored if sent for one-way.

To request upsells in the initial Search response, send maxNumberOfUpsellsToReturn to return up to 4 upsells. For more, you can add the Flight Specific Search API to the workflow. Flight Specific Search is an optional request to return up to 99 upsells (up to as many as the carrier has filed), for any  leg or offer  returned in a preceding Search or Next Leg Search.

Note that you can send Flight Specific Search any time in the workflow after the initial search, and you can send it multiple times. For example, in the last diagram below, you could send Flight Specific Search after Search, either in addition to or instead of sending it after Next Leg Search. Sending Flight Specific Search after the first search allows you consider upsells before requesting options in your Next Leg Search.

Each box in the diagram represents one API call in the workflow.

### Search Workflow options

#### **Search only:** For one-way, journey-based round trip, or multi-city itinerary, with no additional upsells.

```mermaid
flowchart TD
A["Search\n(journey-based)"]
```

#### **Search + upsells:** For one-way, journey-based round trip, or multi-city itinerary, with additional upsells.

```mermaid
flowchart TD
A["Search\n(journey-based)"]
B["Flight Specific Search\n(for product/s on any leg)"]

 A --> B
```

#### **Leg-based Search + Next Leg Search:** For round-trip itinerary returned one leg at a time, with no additional upsells.

```mermaid
flowchart TD
A["Search\n(leg-based)"]
B["Next Leg Search\n(required after leg-based search)"]

 A --> B
```

#### **Leg-based Search + Next Leg Search:** For round-trip itinerary returned one leg at a time, with additional upsells on any leg.

```mermaid
flowchart TD
A["Search\n(leg-based)"]
B["Next Leg Search\n(required after leg-based search)"]
C["Flight Specific Search\n(for product/s on any leg)"]

 A --> B --> C
```