# Save a trip as a template

> Saves a trip as a trip template (Catalog → Trips), as Save trip as template does: its design, its blocks, its quotes as draft proposals, its headcount, presentation and start date.

`POST /v1/trip-templates`

Saves a trip as a trip template (Catalog → Trips), as Save trip as template does: its design, its blocks, its quotes as draft proposals, its headcount, presentation and start date. The trip must have a design (else 422 `trip_has_no_design`). The trip is read as it is now — its itinerary is not synced first. Needs `trips:read` as well. Undo with POST /changes/{changeId}/revert.

**Permissions:** `catalog:write`, `trips:read` · **Kind:** write · **Cost:** 2 units · MCP tool [`save_trip_template`](https://api.bymundi.com/docs/mcp/tools/save_trip_template.md)

Undoable: the response carries `Bymundi-Change-Id`; [revert it](https://api.bymundi.com/docs/guides/undo-and-dry-run.md) with `POST /v1/changes/{changeId}/revert`.

## Path parameters

_None._

## Body

| Field | Type | Required | Description |
|---|---|---|---|
| `tripId` | uuid | yes |  |
| `title` | string | yes | max 200 chars |
| `description` | string |  | max 2000 chars |
| `tags` | string[] |  | Replaces the tags; lowercased. max 20 items |

## Response `201`

| Field | Type | Required | Description |
|---|---|---|---|
| `object` | "trip_template" | yes |  |
| `id` | uuid | yes |  |
| `title` | string | yes |  |
| `description` | string | yes |  |
| `tags` | string[] | yes |  |
| `coverUrl` | string \| null | yes |  |
| `stopCount` | integer | yes |  |
| `updatedAt` | string | yes |  |
| `design` | object | yes |  |
| `design.version` | 1 | yes |  |
| `design.originCity` | string | yes |  |
| `design.stops` | object[] | yes | max 60 items |
| `design.stops[].id` | string | yes |  |
| `design.stops[].city` | string | yes |  |
| `design.stops[].nights` | integer | yes | 0–365 |
| `design.stops[].transferBefore` | object \| null | yes |  |
| `design.stops[].escala` | boolean |  | default false |
| `design.stops[].place` | object |  | default {"placeId":"","lat":null,"lng":null,"formattedAddress":""} |
| `design.returnCity` | string \| null | yes |  |
| `design.returnTransfer` | object \| null | yes |  |
| `design.returnTransfer.id` | string | yes |  |
| `design.returnTransfer.departDate` | string \| null | yes |  |
| `design.returnTransfer.arriveDate` | string \| null | yes |  |
| `design.returnTransfer.days` | integer |  | 0–30, default 0 |
| `design.returnTransfer.departTime` | string |  | default "" |
| `design.returnTransfer.arriveTime` | string |  | default "" |
| `design.returnTransfer.flight` | object |  | default {"flightNo":"","airline":"","fromAirport":"","toAirport":"","source":"","fetchedAt":"","scheduleValidFor":""} |
| `design.originPlace` | object |  | default {"placeId":"","lat":null,"lng":null,"formattedAddress":""} |
| `design.originPlace.placeId` | string |  | default "" |
| `design.originPlace.lat` | number \| null |  | default null |
| `design.originPlace.lng` | number \| null |  | default null |
| `design.originPlace.formattedAddress` | string |  | default "" |
| `design.returnPlace` | object |  | default {"placeId":"","lat":null,"lng":null,"formattedAddress":""} |
| `design.returnPlace.placeId` | string |  | default "" |
| `design.returnPlace.lat` | number \| null |  | default null |
| `design.returnPlace.lng` | number \| null |  | default null |
| `design.returnPlace.formattedAddress` | string |  | default "" |
| `blocks` | object[] | yes |  |
| `proposals` | object[] \| null | yes | The quotes a trip made from it starts with, as drafts; null on a template saved before proposals were kept. |
| `proposals[].name` | string | yes |  |
| `proposals[].mode` | string | yes | `package` (one price, upgrade packages) or `per_item` (the customer picks lines). |
| `proposals[].marginPct` | number | yes |  |
| `proposals[].lineCount` | integer | yes |  |
| `proposals[].wasAccepted` | boolean | yes | Accepted in the trip the template was saved from. |
| `travelers` | integer \| null | yes | The headcount a trip made from it starts with. |
| `presentation` | object \| null | yes | The branding a trip made from it starts with. |
| `baseStartDate` | string \| null | yes | The start date of the trip it was saved from; a new trip's dates shift relative to it. |

## Errors

Errors are [problem details](https://api.bymundi.com/docs/guides/errors.md). Besides the refusals described above, any call like this one can return:

- [`invalid_request`](https://api.bymundi.com/problems/invalid_request.md) — Invalid request
- [`unauthorized`](https://api.bymundi.com/problems/unauthorized.md) — Missing or invalid API key
- [`insufficient_scope`](https://api.bymundi.com/problems/insufficient_scope.md) — Missing permission
- [`rate_limited`](https://api.bymundi.com/problems/rate_limited.md) — Rate limit reached
- [`idempotency_key_reused`](https://api.bymundi.com/problems/idempotency_key_reused.md) — Idempotency-Key reused
- [`request_in_progress`](https://api.bymundi.com/problems/request_in_progress.md) — Request in progress

## Examples

#### curl

```bash
curl -X POST https://api.bymundi.com/v1/trip-templates \
  -H "Authorization: Bearer $BYMUNDI_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"tripId":"<tripId>","title":"string"}'
```

#### JavaScript

```javascript
const res = await fetch("https://api.bymundi.com/v1/trip-templates", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BYMUNDI_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": crypto.randomUUID(),
  },
  body: JSON.stringify({"tripId":"<tripId>","title":"string"}),
});
if (!res.ok) throw new Error((await res.json()).detail);
const data = await res.json();
```

#### Python

```python
import os, uuid, requests

res = requests.post(
    "https://api.bymundi.com/v1/trip-templates",
    headers={"Authorization": f"Bearer {os.environ['BYMUNDI_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
    json={"tripId":"<tripId>","title":"string"},
)
res.raise_for_status()
data = res.json()
```
