FleetOS · for developers

FleetOS API

Dansk: Dette er dokumentationen til udviklere. Bed busselskabet om en API-nøgle – den laves i FleetOS under API og webhooks.

The FleetOS API lets a booking system, tour operator or partner work directly with a coach company's departures in FleetOS: read departures and live ETAs, create bookings – optionally with a taxi from the traveller's door to the coach and back – cancel them, and get webhooks when something changes.

Authentication

The coach company creates an API key in FleetOS and gives it to you. Each key belongs to one company, only has the rights the company ticked, and can be revoked at any time. FleetOS only stores a hash – the key is shown once.

Authorization: Bearer fos_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Base URL: https://api.fleetos.dk. All bodies are JSON (Content-Type: application/json). Times are ISO 8601 (UTC); dates and departure times (dato, afgang) are local Danish time. Field names are Danish – the meaning is listed below.

Departures

GET/api/v1/bus/afgange?fra=2026-12-01&til=2026-12-31

The company's departures. fra defaults to today, til to 30 days after fra (max 92 days).

{ "afgange": [ {
    "id": "6f1c…", "rute": "Næstved – Berlin", "dato": "2026-12-04", "afgang": "06:30",
    "status": "planlagt", "vogn": "12", "pladser": 49, "koerestolspladser": 1, "bestilt": 31,
    "forsinkelse_min": 0,
    "stop": [ { "nr": 0, "navn": "Næstved Station", "adresse": "Jernbanegade 1, 4700 Næstved", "minutter_efter_start": 0 },
              { "nr": 1, "navn": "Køge Nord", "adresse": "…", "minutter_efter_start": 35 } ]
} ] }
FieldMeaning
dato, afgangDate and departure time from the first stop (local time)
pladser, bestiltSeats on the coach, seats booked
statusplanlagt (planned), bekraeftet (running), gennemfoert (completed), aflyst (cancelled)
forsinkelse_minCurrent delay in minutes, from the coach's GPS
stop[].nrStop number – use it as fra_stop / til_stop when booking
GET/api/v1/bus/afgange/{id}

One departure with live ETA per stop (planlagt planned, forventet expected, ankommet arrived), the coach's last position and all bookings.

Bookings

POST/api/v1/bus/afgange/{id}/bookinger

Creates a booking. bookingnr is your booking number and is required: sending the same number again returns the existing booking (status 200, header X-FleetOS-Genkendt) instead of booking twice – safe to retry after a timeout.

curl -X POST https://api.fleetos.dk/api/v1/bus/afgange/6f1c…/bookinger \
  -H "Authorization: Bearer fos_…" -H "Content-Type: application/json" \
  -d '{
    "bookingnr": "TRV-104233",
    "navn": "Grete Hansen",
    "telefon": "+4512345678",
    "antal": 2,
    "fra_stop": 1,
    "koerestol": false,
    "taxa_til_bussen": { "adresse": "Algade 12, 4760 Vordingborg" },
    "taxa_fra_bussen": { "adresse": "Algade 12, 4760 Vordingborg" },
    "saede_oenske": "Gerne foran",
    "sms": true
  }'
FieldMeaning
bookingnr *Your booking number (max 60 characters)
navn *, telefonTraveller's name and mobile number
antalNumber of travellers (1–20, default 1)
fra_stop or afrejsestedBoarding stop: its number, or its name as text
til_stopAlighting stop number (default: last stop)
koerestolWheelchair user
taxa_til_bussen.adresseTaxi from this address to the boarding stop. It arrives in good time before the coach's planned time.
taxa_fra_bussen.adresseTaxi from the alighting stop to this address. It follows the coach's real ETA, so it is there when the coach arrives – also when it is late.
saede_oenskeA seat wish (noted, not guaranteed)
smsfalse = FleetOS does not text the traveller (you do it yourself). Default: the traveller gets one SMS with a live trip link.

Answer 201:

{ "booking": { "bookingnr": "TRV-104233", "afgang_id": "6f1c…", "dato": "2026-12-04", "afgang": "06:30",
    "navn": "Grete Hansen", "antal": 2, "fra_stop": 1, "til_stop": 3, "saeder": [7, 8], "status": "bekraeftet",
    "taxa": [ { "retning": "til_bussen", "status": "bestilt", "afhentning": "2026-12-04T05:20:00.000Z", "adresse": "Algade 12, 4760 Vordingborg" },
              { "retning": "fra_bussen", "status": "bestilt", "afhentning": "2026-12-07T17:43:00.000Z", "adresse": "Algade 12, 4760 Vordingborg" } ] },
  "rejselink": "https://kiosk.fleetos.dk/rejse.html#…" }

rejselink is the traveller's live page (taxi, coach, seats) and is only returned once. A booking is rejected with 409 ingen_plads if the coach is full on that stretch, and a taxi is rejected if the address is outside the area the taxi company may drive in.

GET/api/v1/bus/bookinger/{bookingnr}

Status of one booking, including its taxis.

DELETE/api/v1/bus/bookinger/{bookingnr}

Cancels the booking and its taxis. Nothing is deleted – the status becomes aflyst.

Taxi trips

For taxi companies on FleetOS. The key needs the right taxa (the company ticks it when it creates the key). Prices come from the company's own tariff and are estimates (bindende: false); the company's dispatch assigns the car.

POST/api/v1/tilbud

Price estimate and distance. Send fra and til as an address string or { "adresse", "lat", "lon" }. Optional: tidspunkt (night/weekend tariff), passagerer, vogntype.

{ "pris": { "beloeb": 312, "foer_rabat": 312, "nattakst": false, "valuta": "DKK", "takst": "Standard", "bindende": false },
  "straekning": { "km": 18.4, "minutter": 21 }, "gyldig_til": "2026-12-01T10:15:00.000Z" }
POST/api/v1/ture

Books a trip. jeres_reference is your own reference: sending it again returns the existing trip (header X-FleetOS-Genkendt) – safe to retry. Without tidspunkt the trip is for now.

{ "fra": "Jernbanegade 1, 4700 Næstved", "til": { "adresse": "Kastrup Lufthavn", "lat": 55.6180, "lon": 12.6508 },
  "tidspunkt": "2026-12-04T05:30:00Z", "passagerer": 2,
  "kunde": { "navn": "Anna Hansen", "telefon": "+4512345678" }, "noter": "2 kufferter", "jeres_reference": "HTL-88123" }
GET/api/v1/ture/{id} · GET/api/v1/ture?telefon=&fra_dato=&antal=

One trip, or your trips (newest first, max 200). status: modtaget, tildelt, accepteret, ankommet, ombord, afsluttet, afbestilt.

DELETE/api/v1/ture/{id}

Cancels the trip (body { "aarsag": "…" } optional). A completed or cancelled trip gives 409 kan_ikke_afbestilles.

GET/api/v1/kvittering/{id} · POST/api/v1/ture/{id}/bedom · GET/api/v1/koeretoejer

Receipt for a completed trip; a 1–5 star rating ({ "stjerner", "kommentar" }); the company's active cars with seats and whether they are free (no positions).

StatusfejlMeaning
422ukendt_adresse, ukendt_ruteThe address could not be found – send lat/lon
422uden_for_omraadeThe company's licence only covers trips that start or end in its area
400ugyldigt_tidspunkt, ugyldigt_antalTime in the past or more than a year ahead; passengers not 1–16

Webhooks

The coach company adds your https address in FleetOS and gives you a signing secret (whsec_…). FleetOS then POSTs to you when:

EventWhen
bus.booking.oprettetA booking is created through the API
bus.booking.aflystA booking is cancelled – by you or by the coach company
bus.afgang.forsinketThe coach's expected arrival changes enough to move the taxis home
tur.oprettet, tur.accepteret, tur.ankommet, tur.afsluttet, tur.afbestiltTaxi trips (key right taxa): created, accepted by a car, car at the address, completed, cancelled
test.pingThe company pressed "Send test"
POST https://your-system.example/fleetos
X-FleetOS-Signatur: t=1764000000,v1=5f2b…

{ "haendelse": "bus.booking.aflyst", "sendt": "2026-12-01T10:00:00.000Z", "data": { "bookingnr": "TRV-104233", … } }

Check the signature before you trust the message: HMAC-SHA256 of "{t}.{raw body}" with the secret, compared to v1, and reject messages older than 5 minutes.

const crypto = require('crypto');
function ok(secret, rawBody, header) {
  const p = Object.fromEntries(header.split(',').map((x) => x.split('=')));
  if (Math.abs(Date.now() / 1000 - Number(p.t)) > 300) return false;
  const want = crypto.createHmac('sha256', secret).update(p.t + '.' + rawBody).digest('hex');
  return want.length === p.v1.length && crypto.timingSafeEqual(Buffer.from(want), Buffer.from(p.v1));
}

Answer with any 2xx within 10 seconds. Failed deliveries are retried after 1, 5, 15, 60, 360 and 720 minutes. After 20 failures in a row the receiver is switched off until the company turns it on again.

Errors and limits

Errors have the form { "fejl": "code", "besked": "text" }. React to fejl; besked is for people and may change.

StatusfejlMeaning
401mangler_noegle, ugyldig_noegleNo key, or the key is unknown or revoked
403mangler_rettighedThe key does not have the right bus or taxa
404findes_ikkeNot found (or belongs to another company)
409ingen_plads, allerede_aflyst, afgang_lukketFull, already cancelled, departure closed
429for_mange_kaldMore than 120 calls per minute per key

Questions: help@fleetos.dk