Call it
curl https://api.peume.com/v1/call/find-replacement-flights \
-H "Authorization: Bearer $PEUME_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": {
"run_id": "your run id"
}
}'const res = await fetch("https://api.peume.com/v1/call/find-replacement-flights", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.PEUME_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"input": {
"run_id": "your run id"
}
}),
});
const { output, cost_usd } = await res.json();import os, requests
res = requests.post(
"https://api.peume.com/v1/call/find-replacement-flights",
headers={"Authorization": f"Bearer {os.environ['PEUME_API_KEY']}"},
json={
"input": {
"run_id": "your run id"
}
},
)
print(res.json()["output"])Answer: {"id": "run_…", "status": "completed", "cost_usd": …, "output": {…}}. Long jobs answer 202 with a run id to read later. From an AI agent, connect the MCP server and ask for this by name: find-replacement-flights.
Parameters
run_idRequiredstringrunId of one of YOUR OWN completed /trips/save runs for the trip.
booked_item_idstringThe booked item, from /bookings/get items[].booked_item_id. Preserved across exchanges. Omit only when the booking has exactly one item of the requested domain; otherwise a 409 returns items to choose from.
segments_to_exchangearrayThe legs to change. Each entry is matched to a booked leg by its origin and destination and gives the new departure date. Booked legs you do not list are kept unchanged: every offer is the whole itinerary, with the kept legs as booked. Name each leg by its booked airport codes (`type: airport`): the first departure and the last arrival airport of that journey, as /bookings/get lists the leg — not a connection airport. A city code cannot be matched and is refused. An entry that matches no booked leg is refused with 400 `INVALID_SEGMENTS_TO_EXCHANGE`; a leg that has already departed with 400 `LE
preferred_departure_datestringLegacy. Moves the FIRST leg of the booking to this date and reshops every leg, so it cannot change only a later leg (a return) and can replace the flights of a leg you meant to keep. Use `segments_to_exchange` instead.
