Salta ai contenuti

Autenticazione

Tutte le API fiskaly utilizzano l’autenticazione basata su JWT. Questa guida copre i diversi schemi di autenticazione tra i prodotti.

Chiave API + Segreto → POST /auth (o /tokens) → access_token + refresh_token
├─ Usa nell'header Authorization
└─ Su 401 → aggiorna o ri-autenticati

Questi prodotti usano un endpoint di autenticazione diretto:

curl -X POST https://kassensichv-middleware.fiskaly.com/api/v2/auth \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": "YOUR_API_KEY",
    "api_secret": "YOUR_API_SECRET"
  }'
{
"access_token": "eyJhbGciOiJSUzI1NiIs...",
"access_token_expires_in": 86400,
"refresh_token": "eyJhbGciOiJSUzI1NiIs...",
"refresh_token_expires_in": 172800
}
CampoDescrizione
access_tokenToken JWT valido 24 ore — includere come Authorization: Bearer <token>
refresh_tokenToken valido 48 ore — usare per ottenere un nuovo access token

SIGN ES include la richiesta di autenticazione in un envelope content:

curl -X POST https://test.es.sign.fiskaly.com/api/v1/auth \
  -H "Content-Type: application/json" \
  -d '{
    "content": {
      "api_key": "YOUR_API_KEY",
      "api_secret": "YOUR_API_SECRET"
    }
  }'

Queste API più recenti usano /tokens con il discriminatore content.type e richiedono header aggiuntivi:

curl -X POST https://test.api.fiskaly.com/tokens \
  -H "Content-Type: application/json" \
  -H "X-Api-Version: 2026-02-03" \
  -d '{
    "content": {
      "type": "API_KEY",
      "key": "YOUR_API_KEY",
      "secret": "YOUR_API_SECRET"
    }
  }'

Per limitare le richieste a una specifica UNIT organizzativa, includi l’header X-Scope-Identifier:

Authorization: Bearer <access_token>
X-Api-Version: 2026-02-03
X-Scope-Identifier: <organization_unit_id>

Quando l’access token scade, usa il refresh token invece di ri-autenticarti con le credenziali:

curl -X POST https://kassensichv-middleware.fiskaly.com/api/v2/auth \
  -H "Content-Type: application/json" \
  -d '{"refresh_token": "YOUR_REFRESH_TOKEN"}'
  1. Autenticati una volta all’avvio dell’applicazione
  2. Conserva access_token e refresh_token in memoria
  3. In caso di risposta 401, tenta di aggiornare usando il refresh_token
  4. Se l’aggiornamento fallisce (token scaduto), ri-autenticati con chiave API + segreto
  5. Se la ri-autenticazione fallisce, mostra l’errore all’operatore

Was this page helpful?