Hannk · SDK 2.3.0

Integrating with Hannk, step by step

Branches, fleet, reservations and telematics, for a car rental company's developer. The full field-by-field reference is at hannk.cloud/developers.html.

Integrating with Hannk, step by step

For: the developer at a car rental company connecting their own system (reservations, fleet, back office) to Hannk. SDK: 2.0.0, for the Hannk Partner API v1.

By the end of this guide your system will:

  1. keep your branches in Hannk up to date,
  2. keep your fleet in Hannk up to date,
  3. send every reservation to Hannk, so the customer gets a link, verifies their identity, signs and unlocks the car with their phone,
  4. pull the telematics back out – where each car went, how far, how fast, fuel, warnings and alerts – and process it in your own systems.

Most teams have steps 1–3 working in a day and step 4 in another. Every call in this guide is also a method in the ready-made clients in this pack (node/hannk.js, python/hannk.py, php/Hannk.php), with the same name. API-REFERENCE.md lists every field.


Step 0 – Before you start

Your API key. In the Hannk console, open API in the menu. Your company's key starts hk_live_. Treat it like a password:

One key = one company. Everything you do with it only ever sees and changes your own branches, cars and bookings. No call takes a company id.

The basics of every call:

Base URL https://hannk.cloud
Authentication header Authorization: Bearer hk_live_...
Format JSON in and out (bulk imports also take XML)
Dates and times 2026-11-20T10:30, to the minute, in the branch's local time. A bare date 2026-11-20 means midnight.
Your references Branches use your branch code (e.g. LHR), and reservations use your reference (external_ref, e.g. RC000123). You never have to store Hannk's ids.

Testing. There is no separate test server, so test against your own account carefully:


Step 1 – Check the connection

curl https://hannk.cloud/api/v1/features -H "Authorization: Bearer $HANNK_API_KEY"

You should get {"features":[...]}. A 401 means the key is missing or wrong.

The same call with each client:

// Node 18+
const { Hannk } = require('./hannk');
const hannk = new Hannk(process.env.HANNK_API_KEY);
console.log(await hannk.features());
# Python 3.8+
from hannk import Hannk
hannk = Hannk(os.environ["HANNK_API_KEY"])
print(hannk.features())
// PHP 7.4+ with curl
require 'Hannk.php';
$hannk = new Hannk\Client(getenv('HANNK_API_KEY'));
print_r($hannk->features());

Step 2 – Branches

A branch is where customers collect and return cars. Every car belongs to one, and every reservation names one.

2.1 Create or update a branch – one call does both

PUT /api/v1/branches/{your-code} creates the branch the first time and updates it after that. The minimum is a name and an address. Hannk works out the map position from the address and postcode, or you can send lat and lng.

curl -X PUT https://hannk.cloud/api/v1/branches/LHR \
  -H "Authorization: Bearer $HANNK_API_KEY" -H "Content-Type: application/json" \
  -d '{"name":"Heathrow Airport","address":"Northern Perimeter Road, Hounslow","postcode":"TW6 2SQ","country":"GB"}'
await hannk.upsertBranch('LHR', { name: 'Heathrow Airport', address: 'Northern Perimeter Road, Hounslow', postcode: 'TW6 2SQ', country: 'GB' });

The reply is 201 with action: "created" the first time, then 200 with action: "updated". geocoded: true tells you Hannk found the coordinates for you.

On an update, send only what changed. Fields you leave out keep their value, so {"phones":["+44 20 7946 0000"]} changes the phone number and nothing else.

2.2 The fields worth sending

Field Why it matters
phones A list. The customer's app shows these on the Emergency page and calls them.
opening_hours {"mon":"07:00-22:00", "sat":"08:00-13:00, 15:00-20:00", "sun":"closed"}. Up to four time ranges a day, separated by commas.
pickup_instructions, return_instructions Shown to the customer in the app. Write them in English and Hannk translates them into the customer's language.
btype airport_in, airport_meet_greet, airport_shuttle, city, depot, hotel or other (plain airport is stored as airport_in).
airport_iata LHR, MAN… Send this on airport branches. It makes the app ask the customer for their flight, so the car is held if the flight is late.
timezone, currency, language e.g. Europe/London, GBP, en.
geofence_miles How far, in miles, a car may go from the branch before Hannk raises a warning (60 if not set).
local_radius_miles, local_deposit A driver whose licence address is within the radius is a "local" and pays the local deposit instead.
addl_driver_cost Per day, for each additional driver.
driver_age Young or senior driver surcharges: {"groups":[{"min_age":21,"max_age":24,"cost":15}]}. This is a per-day cost for any driver in that age band.
zone_breach_cost What leaving the permitted area costs per day.
email, website, manager_name, manager_email, ops_email, notes, status Descriptive. status is active or inactive.
admin_feeThis branch's standard admin fee. null clears it back to the company default.
termsThe branch's rental terms & conditions, text or simple HTML up to 200 KB - shown in the app and signed at pick-up (a console-uploaded PDF wins when both exist). Aliases: branch_terms, or rental_terms as [{"no":1,"title":"...","text":"..."}].
cross_borderCountries the branch agrees rentals into, each with a daily_price. The list is authoritative: omit the field to leave them untouched, [] removes them all. JSON only.
local_areaWho counts as local: {"mode":"radius","miles":30}, {"mode":"country"}, {"mode":"state","name":"..."} or {"mode":"city","name":"..."}.

Anything Hannk can't accept comes back as a 400 with every problem listed in problems, so you can fix them all in one pass.

2.3 Load your whole network in one call

POST /api/v1/branches/import takes up to 500 branches at a time, as JSON ({"branches":[...]}) or XML (samples/branches.xml). Branches are matched on code: existing ones are updated and new ones created. The reply has one result per branch, so one bad row doesn't stop the rest.

const r = await hannk.importBranches(myBranches);   // [{code, name, address, ...}, ...]
console.log(r.created, 'created,', r.updated, 'updated,', r.failed, 'failed');
r.results.filter(x => !x.ok).forEach(x => console.log(x.code, x.problems));

Keeping in sync: run the import nightly, or call PUT whenever a branch changes in your system. Both are safe to repeat.

2.4 Read and remove


Step 3 – Fleet

3.1 Add your cars

POST /api/v1/vehicles adds a car, or updates the car with the same registration if Hannk already has it.

await hannk.saveVehicle({
  plate: 'AF69 LFG', brand: 'Toyota', model: 'Corolla', year: 2019,
  acriss: 'CDAR', fuel: 'Hybrid', trans: 'Auto', seats: 5, day_rate: 42,
  addl_driver_cost: 8, local_deposit: 150,
  zx_mode: 'daily', zx_daily: 14.99, zx_max: 150
});
await hannk.saveVehicle({ plate: 'KX21 ABC', brand: 'Kia', model: 'Picanto', no_box: true });

3.2 Telematics boxes

The box in the car is what lets the customer unlock it with their phone, and what produces the data in Step 5. Boxes are ordered from Hannk, and fitting one to a car is done in the console (Fleet). GET /api/v1/telematics/devices lists telematics units that can be connected; sending a device_id with POST /api/v1/vehicles connects one in the same call.

GET /api/v1/vehicles shows which cars have a box (telematics: 1).

3.3 Change, retire

Both are refused while the car is out on a rental, or while a box is still fitted (take the box off in the console first).


Step 4 – Reservations

4.1 What happens to a reservation

your system ── POST /reservations ──▶ Hannk
                                        │ voucher_url (a link for the customer)
customer opens the link ─▶ verifies licence & passport ─▶ signs the agreement
   ─▶ arrives: photos + plate check ─▶ unlocks with the phone ("collected")
   ─▶ drives (telematics recorded) ─▶ returns, photos, locks ─▶ final invoice

Up until the car is collected you can change anything. After that, dates and the car are fixed, and only the branch can close the rental.

4.2 Is there a car?

GET /api/v1/availability?from=...&to=...&branch_code=LHR[&acriss=CDAR] tells you what a booking would get right now. Nothing is held: someone else can take the car before you book, so the booking checks again.

const a = await hannk.availability({ from: '2026-11-20T10:30', to: '2026-11-27T09:00', branch_code: 'LHR', acriss: 'CDAR' });
if (!a.available) console.log(a.code, a.reason, a.free_after);   // e.g. ALL_BUSY, free after 2026-11-22T09:00

4.3 Send the reservation

POST /api/v1/reservations. The smallest booking Hannk accepts:

{
  "external_ref": "RC000123",
  "from": "2026-11-20T10:30",
  "to":   "2026-11-27T09:00",
  "branch_code": "LHR",
  "customer": { "name": "Jane Smith", "email": "jane@example.com" }
}

Always send your own external_ref. It makes a retry safe (the second attempt gets 409 instead of a second booking), and it's how you refer to the booking from then on.

Choosing the car. Use one of these:

Whichever you use, the reply tells you which car it is: registration at the top level, and assignment.mode is requested or allocated. If there's no car, the 409 says why in code:

code Meaning
NO_ACTIVE_VEHICLES The fleet is empty.
NO_SUCH_ACRISS You have no cars of that class. acriss_available lists the classes you do have.
NONE_AT_BRANCH The cars exist but are at other branches.
ALL_BUSY All taken. free_after says when the first one comes back.
VEHICLE_ALREADY_BOOKED The car you named is taken. Leave plate out to let Hannk choose.
VEHICLE_NOT_AT_BRANCH The car you named is at another branch.

Send everything you know. The agreement the customer signs is built from it:

Field
customer name, email, phone, dob (YYYY-MM-DD), address, postcode.
total, deposit_amount, excess_amount Figures for the whole rental.
included What the price covers: ["CDW","Unlimited mileage"].
fuel_policy like_for_like, full_to_full, full_to_empty or empty_to_empty (common spellings such as Full/Full are understood).
deposit_insurance_daily The per-day price if the customer's card can't hold the deposit and they take insurance instead.
charges The priced lines printed on the agreement: [{"code":"RENT","description":"Rental 7 days","qty":7,"unit_price":45,"amount":315,"payment_by":"C"}]. payment_by is C (the renter pays) or A (the agency pays).
products Extras the desk can offer (child seat, GPS…), with sold: true for ones already sold. Sold products become charge lines automatically.
additional_drivers Up to 4 besides the main driver: [{"name":"John Smith","dob":"1983-02-11","email":"...","licence_no":"..."}].
additional_drivers_paid 0-4: how many additional drivers are already paid for when the names are not yet known. Each unnamed place is an included driver slot, filled free of charge at check-in. Names you send count against the paid places; send it again on PUT to change the count.
flight_number e.g. BA2551. At airport branches the car is held if the flight is late.
dropoff_branch_code A different return branch makes it a one-way rental (see below).
allowed_zones Where they may drive, by zone name, chart or id (GET /api/v1/zones lists yours). An unknown name is refused, never silently dropped.
cross_border Countries agreed, each with a daily price: {"agreed":true,"countries":[{"country":"France","daily_price":12}]}. Hannk creates the country geofence if you don't have one.
local_deposit_amount, local_excess_amount, local_included Used instead of the standard figures when the driver turns out to be local to the branch.
agreement_pdf_url or agreement_pdf_b64 Your own pre-filled agreement, if you'd rather the customer signed that.
broker A broker's subdomain, to put their branding on the customer's link.

missing_info is not an error. Every reply lists what Hannk wanted and you didn't send (customer.phone, fuel_policy…). Use it as a checklist for what to add to your integration. GET /api/v1/reservations/{ref}/agreement lists the same for one booking, with whose job each item is.

The customer's link. The reply includes voucher_url. Send it to the customer in your confirmation email; it's how they start. GET /api/v1/voucher-link?ref=RC000123 returns it again at any time.

One-way rentals. When dropoff_branch_code differs from the pick-up branch, the drop-off is recorded on the reservation and shown to the customer. Vehicles are not assigned to branches, so nothing moves and later reservations are unaffected.

4.4 Change a reservation

PUT /api/v1/reservations/{ref}. Send only what changed:

await hannk.updateReservation('RC000123', { to: '2026-11-28T09:00' });                 // a day longer
await hannk.updateReservation('RC000123', { to: '2026-11-28T09:00', vehicle: 'auto' }); // ...and find a car free for it
await hannk.updateReservation('RC000123', { customer: { phone: '+447700900123' } });

4.5 Cancel

DELETE /api/v1/reservations/{ref}?reason=Customer%20cancelled sets the status to cancelled and frees the car immediately; the booking is kept for the record. Add &purge=true to delete it completely (used for test bookings). Cancelling is refused once the car has been collected (ALREADY_COLLECTED) or returned (ALREADY_RETURNED).

4.6 Many at once

POST /api/v1/reservations/import takes up to 500 bookings, as JSON or XML (samples/reservations.xml). Each row goes through exactly the same checks as PUT, matched on external_ref. Use it for the first load and for nightly reconciliation.

4.7 Read back


Step 5 – Telematics: getting the data out and using it

5.1 What is recorded

Every car with a Hannk box reports its position and state through the day. Hannk stores every sample against the car. Each sample can have:

Field Unit Notes
at YYYY-MM-DDTHH:MM When the unit took it.
event text What prompted the report, e.g. a position update, ignition on/off, a door, an alarm.
lat, lng degrees 0, 0 means the unit had no satellite fix. Treat it as "no position", not a place.
speed km/h
direction degrees 0 = north.
odometer km The car's own count when the unit can read it.
fuel_level %
soc_level % Battery charge on electric cars.
battery_voltage V The 12 V battery. A low reading means the car may struggle to start.
temperature °C Inside the car, as the unit measures it.
event_id text The unit's own id for the sample. Use it to de-duplicate.

Any field can be null when that unit can't measure it.

Stored versus live. Every endpoint in this step reads what Hannk has stored except GET /api/v1/vehicles/{id}/status, which asks the car right now. So reports never wait on a car and never cost a call to it. A period that hasn't been synced yet comes back empty with a note saying so; it isn't an error.

Personal data. Where a rented car went is personal data about the person driving it. Use it for running the rental (charges, damage, disputes, safety and fleet care), keep it no longer than you need, and say so in your privacy notice.

5.2 The calls

You want… Call Client method
A board of the whole fleet: where each car is, who has it, what's wrong GET /vehicles/{reg}/everything per car everything
The car right now, live GET /vehicles/{id}/status liveStatus
Every sample in a window, for your warehouse GET /vehicles/{reg}/history (paged) or history.csv history, historyAll, historyCsv
Trips: start, end, km, minutes, top and average speed, the route GET /vehicles/{reg}/journeys journeys
Everything one rental did GET /reservations/{ref}/journeys, /telematics rentalJourneys, rentalTelematics
What's wrong with a car GET /vehicles/{reg}/warnings?state=open warnings
What happened to a car (commands, alerts, moves) GET /vehicles/{reg}/events vehicleEvents
Alerts across the fleet, as they happen GET /events?since=... events
Who has had the car GET /vehicles/{reg}/reservations vehicleReservations

from and to default to the last 7 days. A to that is a bare date means the whole of that day.

5.3 Recipe – load everything into your warehouse every night

// node examples/telematics-export.js  - yesterday's samples for every car, one CSV each
const day = new Date(Date.now() - 86400000).toISOString().slice(0, 10);
for (const v of await hannk.listVehicles()) {
  if (!v.telematics || !v.plate) continue;
  const csv = await hannk.historyCsv(v.plate, { from: day, to: day });
  fs.writeFileSync(`history-${v.plate.replace(/\W/g, '')}-${day}.csv`, csv);
}

The CSV has a header row (timestamp,event,latitude,longitude,speed,direction,temperature,battery_voltage,fuel_level,odometer,soc_level,event_id), starts with a UTF-8 byte-order mark so Excel reads it correctly, and holds up to 200,000 rows. To load JSON instead, historyAll(reg, {from, to}) walks the pages for you. Load on (plate, event_id) so a re-run doesn't duplicate rows.

5.4 Recipe – what did this rental do? (mileage, fuel, time, top speed)

rentalJourneys covers the rental's real window, from when the car was collected to when it came back, so there's no date arithmetic to get wrong.

const j = await hannk.rentalJourneys('RC000123', { points: 'false' });   // points=false: no routes, just the numbers
console.log(j.reservation.collected_at, '->', j.reservation.returned_at);
console.log(j.journeys, 'trips,', j.total_km, 'km,', j.driving_minutes, 'minutes driving');
const top = Math.max(0, ...j.trips.map(t => t.max_speed || 0));

const s = await hannk.rentalTelematics('RC000123');                     // every sample
const withFuel = s.records.filter(r => r.fuel_level != null);
const fuelUsed = withFuel.length > 1 ? withFuel[0].fuel_level - withFuel[withFuel.length - 1].fuel_level : null;  // % of a tank
const odo = s.records.filter(r => r.odometer != null);
const km = odo.length > 1 ? odo[odo.length - 1].odometer - odo[0].odometer : j.total_km;

Each trip has started_at, ended_at, minutes, distance_km with distance_source (odometer where the car reports one, otherwise gps), max_speed, avg_speed, start, end, ended_by and, unless you ask for points=false, the route in points. Each point is [lat, lng, at, speed, {event, direction, odometer, fuel, soc, battery, temp}]. Routes are simplified to at most 400 points a trip. simplified and truncated tell you when that happened, and simplify=false or max_points= change it.

5.5 Recipe – speeding and night driving

recs = hannk.rental_telematics("RC000123")["records"]
LIMIT = 130  # km/h
speeding = [r for r in recs if r["speed"] is not None and r["speed"] > LIMIT]
night = [r for r in recs if r["speed"] and r["at"][11:13] in ("00", "01", "02", "03", "04")]
print(len(speeding), "samples over", LIMIT, "km/h;", len(night), "moving between midnight and 5am")

Hannk doesn't hold road speed limits, so it never scores speeding against them. Use your own threshold, as above.

5.6 Recipe – alerts into your own system

Poll the event feed every minute or so, and keep the newest created_at you have seen:

let since = loadCheckpoint() || new Date(Date.now() - 3600000).toISOString();
setInterval(async () => {
  const evs = await hannk.events(since);               // newest first, up to 500
  for (const e of evs.reverse()) {                     // oldest first
    if (seen(e.id)) continue;                          // de-duplicate on id
    handle(e);                                         // e.type: smoke, impact, zone_breach, battery_low, staff_cmd, ...
    since = e.created_at; saveCheckpoint(since);
  }
}, 60000);

Types worth acting on include smoke, impact, unauthorized, zone_enter, zone_breach (left the permitted area, or a possible tow), battery_low, fuel_low, offline and doc_tag_lost (documents taken out of the car). vehicle_id says which car; GET /vehicles/{id}/everything tells you the rest.

5.7 Recipe – a live fleet board

const board = [];
for (const v of await hannk.listVehicles()) {
  const x = await hannk.everything(v.plate || v.id);
  board.push({ plate: v.plate, at: x.last_seen && x.last_seen.at, lat: x.last_seen && x.last_seen.lat, lng: x.last_seen && x.last_seen.lng,
               out_with: x.on_rental && x.on_rental.customer, next: x.next_reservation && x.next_reservation.from,
               warnings: x.open_warnings.map(w => w.title) });
}

everything reads only what Hannk has stored, so a board of a few hundred cars refreshed every few minutes is fine. Use liveStatus when a person is looking at one car and needs it to be right this second.

5.8 Commands

POST /api/v1/vehicles/{id}/command with {"cmd": "..."} sends a command to the car: lock, unlock, immobilize (the engine won't start), release (it will), blink (flash the lights) or refresh (ask the car for a fresh report). Every command is logged in the car's events as sent by the API.

Unlocking or immobilising a car with a customer in it is a serious act. Build it so a person has to decide, never as an automatic reaction to an alert. The telematics box itself refuses to immobilise a moving car.


Step 6 – Errors, retries and safety

Every error is JSON:

{ "error": "A sentence you can show a person.", "code": "A_STABLE_CODE", "problems": ["every validation problem at once"] }
Status Meaning What to do
400 Something in the request needs fixing. Fix everything in problems. Don't retry unchanged.
401 No key, or an unknown key. Check the key.
404 No such branch, car or booking in your account. Check the reference.
409 It exists, but can't be done right now. Branch on code (see 4.3).
502 The car or its box didn't answer. Retry with backoff.
500 Hannk failed. Retry later. If it keeps happening, tell Hannk support with the time and the call.

Step 7 – Go-live checklist

Questions about the API: your Hannk contact, or sales@hannk.com. Include the time, the call you made and the external_ref or registration, and never your API key.