Developers · Getting started

Authentication and keys

Live and test API keys, the read and write scopes, key creation, rotation and revocation for the Battery Passport API.

Version
v1.0.0
Base URL
https://dppapi-production.up.railway.app/v1
Format
JSON · OpenAPI 3.1
FeedbackLast updated

Este artículo aún no está disponible en español; se muestra a continuación en inglés.

On this pageAPI keys

API keys

The API authenticates with secret keys that belong to your organisation. A signed-in user creates them in the app under Organisation → API keys, gives each a name and chooses its scopes. A key acts for the organisation, not for the person who created it, and sees exactly that organisation’s models, batteries and passports.

Keys look like dpp_live_ or dpp_test_ followed by 40 hexadecimal characters. The full key is shown exactly once, when it is created. We store only its SHA-256 hash, so nobody — including us — can show it to you again. We also keep the first few characters of each key, so keys can be told apart.

Key format
# Illustrative — not a real key.# dpp_live_ + 40 hex characters. The first part (dpp_live_3f9a) is kept to tell keys apart.dpp_live_3f9a0c5e7b1d24a68e0f9c3b5d7a1e2f4c6b8d0a

Live and test keys

Live keyTest key
Prefixdpp_live_…dpp_test_…
WritesStoredDry run: validated, never stored
Rate limit600 / minute60 / minute
X-DPP-Modelivetest

Both read your real data. Develop and run CI with a test key, deploy with a live key — see test keys and dry runs.

Sending the key

Send the key as a bearer token in the Authorization header of every request. Keys work only on /v1/*paths; the app’s own endpoints do not accept them, and the public resolver does not need one.

curl "https://dppapi-production.up.railway.app/v1/me" \-H "Authorization: Bearer $DPP_API_KEY"

A request with no key, a malformed key, an unknown key or a revoked key is answered with 401 unauthorized. GET /me is the simplest way to check a key: it returns the key, its scopes and mode, your organisation, plan, usage and rate limit.

Scopes

Each key carries one or both scopes. The scope is checked against the HTTP method of the request:

ScopeMethodsGrants
readGETRead models, documents, batteries, passports, events, versions, QR codes, the audit trail, the field catalogue, webhooks and exports.
writePOST, PATCH, PUTCreate and update models and facilities, upload documents, send supplier requests, create batteries, publish, record events, change status, recycle, run fleet updates and manage webhook endpoints.

A write with a key that only has read is refused with 403 and insufficient_scope. DELETE is refused for every key, whatever its scopes, with 403 and method_not_allowed_for_api_keys — see why there is no DELETE.

403 · read-only key used for a write
{"error": "insufficient_scope","message": "This API key does not have the \"write\" scope.","request_id": "3f1c2a9e-8d4b-4c6f-9e2a-7b5d1c0e8f34"}

Rotation and revocation

Revoking a key in the app takes effect immediately: the next request with it is answered with 401. A revoked key cannot be restored. To rotate without downtime, create the new key, deploy it, confirm traffic with GET /me, then revoke the old one.

Good practice

  • One key per integration (ERP, MES, BMS gateway), named after it, so one can be revoked without stopping the others.
  • Give each key the least scope it needs: a reporting job or dashboard only needs read.
  • Keep keys in a secret manager or environment variable, never in source code, front-end bundles or mobile apps.
  • Call the API from your servers. Keys are organisation-wide secrets and must not reach a browser.

Preferencias de cookies

Tú decides qué cookies se usan. Puedes cambiar tu elección en cualquier momento desde «Configuración de cookies» en el pie de página. Política de privacidad

Necesarias

Siempre activas

Imprescindibles para que el sitio funcione: tu tema claro/oscuro y esta elección de cookies se guardan en tu navegador. No sirven para rastrearte.

Analítica

Google Analytics 4 mide cómo se usan las páginas mediante estadísticas, lo que nos ayuda a mejorar el sitio. Si aceptas, instala cookies y mide tu visita por completo. Si rechazas, no instala cookies, pero Google aún puede recibir datos técnicos como la página vista, el tipo de navegador y la dirección IP.

_ga, _ga_* · hasta 2 años · Google