All insights

A fleet management API explained: uses, security and what to check

What a fleet management API is, what companies connect it to, and the six properties to check: key authentication, scopes, rate limits, pagination, idempotency keys and signed webhooks.

Technology 14 minutes

Key points

  • A fleet API has two directions: your system pulls data (positions, trips, statistics) and pushes changes (jobs, drivers, geofences). A webhook adds a third, where the platform calls your system when an event occurs.
  • A key should carry only the scopes one integration needs, be shown once, be stored as a hash by the provider, and be revocable by the account owner at any time.
  • A rate limit is part of the contract: the API should answer 429 with a Retry-After header, and your client should wait that long, not retry at once.
  • Every list must be paged with a cursor and a hard maximum page size, so that a large fleet never returns one unbounded answer.
  • A write that can be repeated needs an idempotency key, so that a network retry creates one job, not two.
  • A webhook must be signed with an HMAC, carry a timestamp that the receiver checks, and be treated as at-least-once: the receiver removes duplicates and orders by the event's own time.

A fleet management API is the interface through which your own software reads fleet data and writes changes to it without anyone using the console. An ERP takes trips and mileage, a payroll system takes working time, a dispatch tool creates jobs, and a BI tool takes daily statistics. Whether the connection is safe and stays up depends on six properties of the API: how keys are issued, what scopes limit them, how rate limits answer, how lists are paged, whether a retried write is safe, and how webhooks are signed.

Polling the API or receiving a webhook
NeedPoll the APIUse a webhook
Nightly load into a warehouseYes: read trips and daily statistics by dateNo
Act soon after an alarmWasteful: a call every few secondsYes: the event arrives as it opens
Know a job was completedPossible, with a short intervalYes: job completed event
Catch up after your system was downYes: read from the last time you holdNo: after a long outage the endpoint is disabled and must be turned back on
Reconcile a master listYes: page through vehicles and driversNo

What a fleet management API is

An application programming interface (API) is a set of requests a program may make to another program and the answers it gets. For a fleet, the other program is the tracking platform: its vehicles, drivers, trips, alarms and jobs are exposed as resources that a program reads and changes.

A modern fleet API follows the same pattern as most web APIs. Each resource has an address under a version prefix, a request carries a method that says what is wanted, and the answer is JSON with a status code. The contract is written in the OpenAPI Specification, a machine-readable description that developers use to read the API, generate a client and test against it. An integration is the code that uses the API, and a webhook is the reverse direction: the platform calls an address you provide when an event occurs.

What companies connect a fleet API to

Six uses cover most connections to a fleet API:

  • ERP and finance: trips, mileage and fuel events per vehicle and day feed cost allocation to a contract or a cost centre. The data and its limits are in the ERP integration post.
  • Payroll and HR: driver sessions, trips and stops give start and end times, and a driver's scores and coaching sessions can be read for review. The API supplies the times; the payroll rules stay in the payroll system.
  • Dispatch and customer systems: a job with ordered stops is created from the order system and dispatched through the API. Its progress comes back as job events and the stops' states.
  • Business intelligence: daily statistics per vehicle, trips and driving scores are loaded on a schedule into a warehouse and combined with sales or maintenance data.
  • Alerting and operations tools: alarms are read, assigned, acknowledged and closed from the tool where the operations team already works, with webhooks to start the flow.
  • Master data: vehicles, drivers, groups and geofences are created and changed from the system that owns them, so the fleet list is typed once.

Pick the system of record for each field before building. Where two systems can both change a driver's name, the API makes the conflict faster, not smaller.

Keys and scopes: who may call the API and for what

An integration holds a credential, so how it is issued and limited matters more than any endpoint. Look for four things:

  • Key authentication: a key is sent as a bearer token in the Authorization header, the scheme defined in RFC 6750. A good provider shows the key once and stores only its hash, so a leak at the provider does not expose it, and lets the account owner revoke it at once.
  • Scopes: a key carries named permissions such as read vehicles or write rules, and the API refuses a call outside them. A BI feed holds a read scope and cannot create a job.
  • Data scope: a key may also be limited to a department's vehicles, so a regional integration sees its own part of the fleet.
  • Transport: HTTPS only. A key sent in clear text is a leaked key.

Treat the key like a password. Fleet data security covers the account side: roles, two-step sign-in and who can see what.

Rate limits and pagination: how a client behaves

A rate limit keeps one client from using the capacity the others need. The status for exceeding it is 429 Too Many Requests, defined in RFC 6585, and the answer may say how long to wait in a Retry-After header, a field defined in RFC 9110. A limit is usually a rate with a burst allowance, so a client may send a short run of calls and then settles to the steady rate, plus a daily quota.

A client built for this does three things. It reads Retry-After and waits that long, it adds a random delay when it retries so that many clients do not retry together, and it asks for less: a filter by time or vehicle and a daily statistics call replace a loop that reads every position.

Lists need the same care. A list that returns every vehicle in one answer fails when the fleet grows. A cursor pages it: the answer holds a page of records and a next cursor, the client passes the cursor to get the following page, and the last page has no cursor. A maximum page size protects both sides. A client that follows the cursor until it is empty reads every record once, and one that stores the cursor can resume after a failure.

Idempotency keys and errors: making a retry safe

A network can fail after a request arrives and before the answer returns. The client then does not know whether the job was created. Reading again is safe, because a read changes nothing, and RFC 9110 names PUT and DELETE idempotent too: repeating them leaves the same result. POST, the usual method for creating, is not idempotent, so a blind retry can create a second job.

An idempotency key solves it. The client sends a unique key with the create call, and the API remembers the first result for that key for a set time. A retry with the same key returns the first result and creates nothing. Choose a key you can build again for the same business event, such as the order number, so that a client restarted after a crash sends the same key.

Errors need a stable shape as well. RFC 9457 defines a problem-details body with a type, a title, a status and a machine-readable code, so a client branches on the code and shows the detail to a person.

Webhooks: signed, repeated and out of order

A webhook is a call into your system, so you must be able to tell it from a forged one. A sound design has six parts:

  • Signature: the provider computes an HMAC, a keyed hash defined in RFC 2104, over the timestamp and the exact body with a secret that only the two sides know. The receiver computes the same value and compares it, using a constant-time comparison.
  • Timestamp: the signed value includes the time. A receiver rejects a call whose time is far from its clock, which stops an attacker from replaying a captured call.
  • At-least-once delivery: a call that does not get a 2xx answer is tried again, so the same event can arrive twice. The receiver stores each event id and ignores a repeat.
  • No promised order: events can arrive out of sequence, so the receiver orders by the time inside the payload, not by arrival.
  • Quick answer: the receiver returns 2xx first and does the slow work after, because a slow answer counts as a failure.
  • Safe destinations: the provider should accept only https addresses on public hosts and follow no redirects, so that an endpoint cannot be turned against a private network.

A signature proves who sent the call. It does not hide the content, which is why the address must be https.

What the PING API offers

PING publishes its API under a version prefix, v1, with these properties:

  • Authentication: keys start with ping_live_ and go in the Authorization header as a bearer token. The account owner issues and revokes keys in the console, up to 20 active keys per account, and only a hash of the secret is stored. The key is shown once.
  • Scopes: fleet, telemetry, rules, devices, accounts and webhooks data has read scopes, and fleet, rules, accounts, webhooks and reports have write scopes. A key can also be limited to the whole account, a department tree or a single department.
  • Rate limits: each key gets 10 calls a second with a burst of 50 and a quota of 100,000 calls a day. Beyond it the API answers 429 with Retry-After and RateLimit headers.
  • Pagination: lists take limit and cursor, with a default of 50 and a maximum of 200, and answer with data and next_cursor.
  • Idempotency: create calls accept an Idempotency-Key header of up to 128 characters. A retry with the same key within 24 hours returns the first result.
  • Errors and times: errors are RFC 9457 problem bodies, and times are RFC 3339 in UTC.
  • Webhooks: nine event types (alarm opened and cleared, trip ended, geofence entered and exited, and job dispatched, started, completed and cancelled), signed in a Ping-Signature header as t=<unix seconds>,v1=<hex HMAC-SHA256 of the timestamp, a dot and the body>. Receivers should reject a timestamp more than 300 seconds from their clock. Event, type and delivery ids come in headers. Secrets start with whsec_ and are shown once; rotating one takes effect at once. A test event can be sent to an endpoint, a delivery log is kept, and an event can be redelivered.

Every operation, scope and event is in the API reference, which is generated from the same OpenAPI description a developer can download.

What to ask before you plan an integration

Put these to any provider before you plan an integration:

  • Who may issue keys, and how many may exist at a time.
  • The scopes, and whether a key can be limited to a department.
  • The rate limit, the burst and the daily quota, and what the 429 answer contains.
  • The maximum page size and how a list tells you it has ended.
  • Which calls take an idempotency key and how long it is remembered.
  • How a webhook is signed, how long a timestamp is accepted, and what happens when your endpoint is down.
  • Whether the description is a published OpenAPI file, and whether errors have a stable code.
  • How a key or secret is revoked and rotated.

A check before connecting a system to a fleet API

  • One key per integration, named for the system that holds it, so that one can be revoked without breaking the others.
  • Each key has the narrowest scopes and the narrowest data scope it needs: read-only for a BI feed.
  • Keys sit in the integration's secret store, never in code, a repository, a log or a URL.
  • The client reads the Retry-After header on a 429 and waits, and its polling stays below the key's rate limit.
  • Every list call follows the next cursor until it is empty, with a page size at or under the maximum.
  • Every create call sends an Idempotency-Key, and a retry reuses the same key.
  • A webhook receiver verifies the signature on the raw body, rejects a timestamp outside five minutes, and answers 2xx before slow work.
  • The receiver removes duplicate events by event id and orders by the event's own time.
  • A test event has been sent to the endpoint, and the delivery log has been read once.
  • Keys and webhook secrets are rotated on a schedule and when a person who knew them leaves.

Questions

What is a fleet management API?

A fleet management API is an interface over HTTPS in which a vehicle, a trip or a job is a resource with an address, read with GET and changed with POST, PUT, PATCH or DELETE, and answered in JSON. The structure is published as an OpenAPI description, which a developer can read and generate a client from.

Does a fleet API replace the console?

No. The API sends and receives the same data the console shows, in a form a program can read. Without the API a person exports a file or retypes a number. With it, trips, driver data and jobs flow between systems on their own, and the console remains the place to see the fleet.

How do I get access to a fleet API?

Ask the account owner to issue a key in the console, give it only the scopes the integration needs, and send it in the Authorization header as a bearer token. The key is shown once, so it goes straight into the integration's secret store.

Should I poll the API or use webhooks?

Poll when your system needs the state on a schedule, such as yesterday's trips each morning. Use a webhook when it must act soon after an event, such as an alarm or a completed job. A webhook saves repeated polling, and a daily poll remains the way to catch up after downtime.

What happens when I exceed a fleet API's rate limit?

The API answers with status 429 and a Retry-After header giving the seconds to wait. The client waits that long and tries again. If it keeps retrying at once it stays blocked, so a client should slow its polling and spread its calls.

Why must a webhook receiver verify the signature?

Checking the signature and the timestamp is what proves the call came from the platform and is current. Without it, anyone who learns the endpoint's address can send it false events. The signature is computed over the exact body, so verify it before parsing.

Why does a create call need an idempotency key?

Retrying a create call after a timeout can create the record twice, because the first call may have succeeded. An idempotency key identifies the attempt, so the API returns the first result for a repeat instead of creating again.

The endpoints, scopes and webhook events are in the API reference, and the systems it connects to are on the integrations page. To plan a connection for your own systems, contact us.

Sources

  1. OpenAPI Initiative: OpenAPI Specification 3.1.0
  2. IETF RFC 6750: Bearer Token Usage
  3. IETF RFC 6585: Additional HTTP Status Codes (429)
  4. IETF RFC 9110: HTTP Semantics (Retry-After, idempotent methods)
  5. IETF RFC 9457: Problem Details for HTTP APIs
  6. IETF RFC 2104: HMAC, keyed hashing for message authentication