Skip to main content

Trip Templates

Templates are blueprints for recurring routes. They store all trip configuration except status and timestamps. Weight is a default suggestion only — users must confirm or change it every time a trip is created from a template.

Template Fields​

FieldTypeDescription
idUUIDTemplate ID
namestringTemplate name
descriptionstring?Optional description
category_idUUID?Transport category
origin_idUUID?Sender location
destination_idUUID?Receiver location
device_idUUID?Default GPS device
gps_logging_enabledboolWhether GPS logging should be enabled by default
default_weight_kgfloat?Pre-fill suggestion — user must confirm
notesstring?Free-text notes
tagsstring[]Default tags

No status, started_at, or ended_at — templates are blueprints, not active trips.

REST Endpoints​

MethodPathPermissionDescription
GET/v1/trip-templatestrips:readList templates
GET/v1/trip-templates/{id}trips:readGet template
POST/v1/trip-templatestrips:writeCreate template
PATCH/v1/trip-templates/{id}trips:writeUpdate template
DELETE/v1/trip-templates/{id}trips:deleteDelete template
POST/v1/trip-templates/{id}/create-triptrips:writeCreate trip from template

GraphQL​

  • tripTemplates → [GqlTripTemplate] (no arguments, flat list)
  • tripTemplate(id) → GqlTripTemplate
  • createTripTemplate(input) → GqlTripTemplate
  • updateTripTemplate(id, input) → GqlTripTemplate
  • deleteTripTemplate(id) → Boolean
  • createTripFromTemplate(templateId: UUID!, weightKg: Float!) → GqlTrip

Create Template​

POST /v1/trip-templates
{
"name": "Mannheim → Köln (Schrott)",
"category_id": "<schrott-uuid>",
"origin_id": "<mannheim-uuid>",
"destination_id": "<koeln-uuid>",
"device_id": "<peplink-uuid>",
"gps_logging_enabled": true,
"default_weight_kg": 24000,
"tags": ["recurring", "rhein"]
}

Create Trip from Template​

POST /v1/trip-templates/{id}/create-trip

{ "weight_kg": 23500 }

Or via GraphQL:

mutation {
createTripFromTemplate(templateId: "<id>", weightKg: 23500) {
id
name
status
weightKg
}
}

The created trip has status: "draft". weight_kg is required — even if the template has a default_weight_kg, the caller must explicitly pass the confirmed weight.

Using Templates​

Templates can be used in two ways:

  1. From Templates page — Click "Use Template" on any template card, redirects to /trips/create?template=ID
  2. From Trip Create page — Select a template from the "Load from template" dropdown at the top of the form

When a template is loaded, all form fields are pre-filled (name, description, origin, destination, category, weight, GPS settings, device, tags, notes). The weight field is highlighted and required for confirmation.

Save as Template​

On the trip create page, click "Save as Template" to save the current form values as a new template. The template name defaults to the trip name but is editable.

GraphQL Note​

The tripTemplates query returns a flat Vec<GqlTripTemplate> (not paginated). The API route wraps the response in the standard { items, total, page, limit, has_more } format for frontend consistency.