# Change the itinerary

> The apply_itinerary_changes MCP tool: change the itinerary.

`apply_itinerary_changes` · writes · destructive

MCP only (no REST operation).

## What the model reads

Applies a list of block operations to one trip's itinerary, all or nothing, with the app's own validation, and re-plans the route of every day it touches. Ops:
- add: a new block of `type` under `parentId` (absent = the root), at `position` among its siblings. Give it a `clientId` to use it as a later op's parentId or anchorId.
- update: MERGES `data` into the block (send only the fields you change) and/or patches `layout`.
- move: to `parentId` at `position`.
- delete: the block and everything inside it.
Name blocks by the refs get_itinerary printed, or by full id. Versions are optional: absent = the current one; one you send is checked, and a stale one is refused.
Refused: `dia` structure ops on a trip whose days come from its design (change the design with update_trip, then sync_itinerary), a batch that changes nothing, and deleting a retired block type. Deleting more than 5 blocks or 30% of the itinerary needs `confirm` set to the trip's exact title.

`data` fields by block type — use exactly these names; an unknown field is refused. Rich-text fields accept plain text.
`catalogRef` takes only an id a tool returned (search_catalog, search_places, suggest_routes), as {"kind":"punto","id":"…"}.
- titulo: text:string
- texto: markdown:rich text
- imagen: assetId:string, url:string, alt:string, caption:string, width:number, height:number
- agenda: title:string, mode:one of(tabs|accordion|timeline), showDates:boolean, showTitleInTabs:boolean, showMap:boolean
- dia: date:string(YYYY-MM-DD), title:string, location:string, description:rich text | set by bymundi, leave out: locationPlace, window
- caja: title:string, body:rich text, color:string
- desplegable: title:string, open:boolean
- seccion: key:one of(transportes|alojamiento|actividades|comidas), title:string, description:rich text
- capitulo: key:one of(bienvenida|hoteles|vuelos|info-practica|contactos|custom), title:string, icon:string
- derivado: kind:one of(hoteles|vuelos)
- actividad: title:string, time:string(HH:MM), durationMin:number, location:string, meetingPoint:string, description:rich text, tips:rich text, warnings:rich text, arrival:rich text, paidEntry:boolean, priceNote:string, bookingUrl:string, catalogCategory:string, hideTips:boolean, confirmationCode:string, optional:boolean, hideSchedule:boolean | set by bymundi, leave out: locationPlace, hours, image
- alojamiento: hotel:string, roomType:string, board:one of(room_only|breakfast|half_board|full_board|all_inclusive), checkIn:string(YYYY-MM-DD), checkOut:string(YYYY-MM-DD), address:string, nights:number, notes:rich text, catalogCategory:string, confirmationCode:string, optional:boolean, hideSchedule:boolean | set by bymundi, leave out: place, image
- vuelo: title:string, from:string, to:string, departAt:string(YYYY-MM-DDTHH:MM), arriveAt:string(YYYY-MM-DDTHH:MM), stopovers:list[place:string, arriveAt:string(YYYY-MM-DDTHH:MM), departAt:string(YYYY-MM-DDTHH:MM)], flight[flightNo:string, airline:string, fromAirport:string, toAirport:string], confirmationCode:string, optional:boolean, hideSchedule:boolean | set by bymundi, leave out: fromPlace, toPlace, image
- transporte: title:string, from:string, to:string, mode:string, travelMode:one of(|walking|transit|driving|bicycling), durationMin:number, provider:string, serviceNo:string, seat:string, departAt:string(YYYY-MM-DDTHH:MM), arriveAt:string(YYYY-MM-DDTHH:MM), stopovers:list[place:string, arriveAt:string(YYYY-MM-DDTHH:MM), departAt:string(YYYY-MM-DDTHH:MM)], description:rich text, catalogCategory:string, confirmationCode:string, optional:boolean, hideSchedule:boolean | set by bymundi, leave out: fromPlace, toPlace, image
- informacion: variant:one of(info|tip|warning|important), title:string, body:rich text
- galeria: columns:one of(2|3|4) | set by bymundi, leave out: items
- video: url:string, caption:string
- mapa: query:string, zoom:number, caption:string | set by bymundi, leave out: place

Permissions: trips:write.
Set `dryRun: true` to preview the effect without writing anything.
Undo: the result names a change id; undo_change reverts it.

## Input

| Field | Type | Required | Description |
|---|---|---|---|
| `tripId` | uuid | yes |  |
| `ops` | object \| object \| object \| object[] | yes | max 200 items |
| `confirm` | string |  | max 300 chars |
| `dryRun` | boolean |  | Preview only: plan the change and return its effect without writing. |

## Input schema (JSON)

```json
{
  "type": "object",
  "properties": {
    "tripId": {
      "type": "string",
      "format": "uuid"
    },
    "ops": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "op": {
                "type": "string",
                "const": "add"
              },
              "type": {
                "type": "string",
                "enum": [
                  "titulo",
                  "texto",
                  "imagen",
                  "agenda",
                  "dia",
                  "caja",
                  "desplegable",
                  "seccion",
                  "capitulo",
                  "derivado",
                  "actividad",
                  "alojamiento",
                  "vuelo",
                  "comida",
                  "transporte",
                  "tren",
                  "crucero",
                  "informacion",
                  "galeria",
                  "video",
                  "mapa",
                  "html",
                  "itinerario"
                ]
              },
              "parentId": {
                "anyOf": [
                  {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 64
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The parent: a ref, an id, or the clientId of an earlier add. Absent or null = the root."
              },
              "position": {
                "type": "string",
                "enum": [
                  "start",
                  "end",
                  "after",
                  "before"
                ],
                "description": "\"end\" (default), \"start\", or \"after\"/\"before\" the anchorId sibling."
              },
              "anchorId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64
              },
              "data": {
                "type": "object",
                "additionalProperties": {},
                "description": "Only the fields you set; an update MERGES into the block's data."
              },
              "layout": {
                "type": "object",
                "properties": {
                  "colSpan": {
                    "type": "number",
                    "enum": [
                      1,
                      2,
                      3
                    ]
                  },
                  "hidden": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false
              },
              "clientId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64,
                "description": "Your name for the new block, so a later op in this call can use it as parentId or anchorId."
              }
            },
            "required": [
              "op",
              "type"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "op": {
                "type": "string",
                "const": "update"
              },
              "id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64
              },
              "data": {
                "type": "object",
                "additionalProperties": {},
                "description": "Only the fields you set; an update MERGES into the block's data."
              },
              "layout": {
                "type": "object",
                "properties": {
                  "colSpan": {
                    "type": "number",
                    "enum": [
                      1,
                      2,
                      3
                    ]
                  },
                  "hidden": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false
              },
              "expectedVersion": {
                "type": "integer",
                "minimum": 0,
                "description": "Optional: the version you read. Absent = the current one."
              }
            },
            "required": [
              "op",
              "id"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "op": {
                "type": "string",
                "const": "move"
              },
              "id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64
              },
              "parentId": {
                "anyOf": [
                  {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 64
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "position": {
                "type": "string",
                "enum": [
                  "start",
                  "end",
                  "after",
                  "before"
                ]
              },
              "anchorId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64
              }
            },
            "required": [
              "op",
              "id",
              "parentId"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "op": {
                "type": "string",
                "const": "delete"
              },
              "id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64
              },
              "expectedVersion": {
                "type": "integer",
                "minimum": 0,
                "description": "Optional: the version you read. Absent = the current one."
              }
            },
            "required": [
              "op",
              "id"
            ],
            "additionalProperties": false
          }
        ]
      },
      "minItems": 1,
      "maxItems": 200
    },
    "confirm": {
      "type": "string",
      "maxLength": 300
    },
    "dryRun": {
      "type": "boolean",
      "description": "Preview only: plan the change and return its effect without writing."
    }
  },
  "required": [
    "tripId",
    "ops"
  ],
  "additionalProperties": false
}
```
