Skip to content

Vehicle lookup — going live

The DVLA + DVSA APIs are free with registration. Both halves are independent: you can register them in either order, and the system keeps working in mock mode until both sets of secrets are in place. Plan ~1 working week end-to-end — both DVLA and DVSA take up to 5 working days for approval (DVSA used to be instant on the developer portal but tightened the process in 2026).

1. DVSA MOT History API (~5 working days)

Returns: full MOT test history per VIN — pass/fail, expiry date, mileage at each test.

  1. Go to https://documentation.history.mot.api.gov.uk/ and click Sign up. You'll be asked to create / sign in to a Microsoft Entra (Azure AD) account.
  2. Register an "application" — give it a name like lifefile-prod. Note the Tenant ID (looks like a UUID).
  3. From the application page, copy:
  4. Client ID
  5. Client secret (only shown once — store it now)
  6. API key (separate from the secret; appears under "API keys")
  7. The default Scope is https://tapi.dvsa.gov.uk/.default — leave that as-is unless DVSA tells you otherwise.

Free-tier caps: 500,000 requests/day, 15 req/sec sustained, 10 burst. We cache the result on the VehicleProfile, so per-household volume is ~one call per vehicle per refresh — orders of magnitude inside the limits.

2. DVLA Vehicle Enquiry Service (~5 working days)

Returns: make, year, fuel, engine, colour, CO₂, current tax + MOT status. No model name — only make.

  1. Apply at https://developer-portal.driver-vehicle-licensing.api.gov.uk/.
  2. Fill in the application form. They want:
  3. Org details (use your name + LifeFile as the use-case description)
  4. Expected request volume — say "low — single-user / small household filing app, under 100 lookups/day"
  5. A short description of what you're using the data for
  6. After ~5 working days you'll get an approval email containing a single API key (DVLA only issues one per customer — don't request more).
  7. Note: emails about renewal land at the address you registered with; the key itself doesn't expire on a clock but DVLA can revoke if misuse is detected.

Free-tier caps: per-second throttling per subscription; the exact daily quota is shown in your portal after approval. For our use case (cached on the model) this is fine.

3. Set the secrets in Fly

fly auth whoami                          # confirm olly.willans@gmail.com
fly secrets set -a lifefile \
  DVLA_VES_API_KEY="…" \
  DVSA_MOT_CLIENT_ID="…" \
  DVSA_MOT_CLIENT_SECRET="…" \
  DVSA_MOT_TENANT_ID="…" \
  DVSA_MOT_API_KEY="…"

The DVSA_MOT_SCOPE default (https://tapi.dvsa.gov.uk/.default) is set in config/settings.py and doesn't need overriding.

4. Flip to live mode

In fly.toml under [env], change:

VEHICLE_LOOKUP_MODE = 'live'

…or one-shot it without a deploy:

fly secrets set -a lifefile VEHICLE_LOOKUP_MODE=live

(Setting it as a secret overrides the [env] value, which is fine for a quick flip.)

5. Smoke test

After deploy:

  1. Add a vehicle from the dashboard, give it your real plate.
  2. Confirm the DVLA panel populates (make, year, fuel, MOT status, tax status).
  3. Click Refresh — confirm it stays the same and lookup_at updates.
  4. If something fails, the panel shows Last lookup hit issues: … — the same message is logged server-side at WARNING level. Check fly logs for the underlying HTTP error.

Rollback

Set VEHICLE_LOOKUP_MODE=mock and redeploy. Existing VehicleProfile rows aren't touched — they'll just stop refreshing.

What it costs

£0 forever, both APIs, until either of the following: - DVSA changes their pricing model (no public roadmap to do so). - We genuinely exceed the free quotas (we won't — see caps above). - We want commercial enrichment like trim, valuation, finance status. UKVehicleData and similar are ~£0.05–£0.20 per call. Not needed for v1; revisit if a richer lookup becomes a paid feature.