Skip to main content

Authentication

FiscalAPI uses Bearer token authentication with API keys.

API key format

API keys follow the format:

fsk_{environment}_{64 hex characters}
PrefixEnvironmentUsage
fsk_test_TestDevelopment and testing
fsk_live_LiveProduction

Using your API key

Include the API key in the Authorization header:

curl https://api.fiscalapi.com/v1/locations \
-H "Authorization: Bearer fsk_test_abc123def456..."

Key lifecycle

  1. Creation: An API key is generated when you create an account. The plaintext key is returned only once.
  2. Storage: FiscalAPI stores a SHA-256 hash of the key. The plaintext cannot be retrieved after creation.
  3. Revocation: Keys can be revoked, making them permanently unusable.
caution

Store your API key securely immediately after account creation. If lost, you'll need to generate a new key.

Test vs live mode

The API key prefix determines the environment for each request:

  • fsk_test_ keys route fiscalization to sandbox tax authority endpoints. Use these during development and testing.
  • fsk_live_ keys route fiscalization to production tax authority endpoints. Requires the server to have live mode enabled.

Transactions include an environment field ("test" or "live") reflecting which mode was used.

If live mode is not enabled on the server, requests with fsk_live_ keys return 403 Forbidden:

{
"error": "live mode is not enabled"
}

See the Sandbox routing guide for more details.

Public endpoints

The following endpoints do not require authentication:

EndpointDescription
GET /healthService health check
GET /versionAPI version information
POST /v1/accountsAccount creation

Error responses

StatusErrorCause
401missing or invalid Authorization headerNo Authorization header provided
401invalid API key formatKey doesn't match expected format
401invalid API keyKey not found or hash mismatch
401API key has been revokedKey was revoked
403account is not activeAccount suspended or cancelled

Example error response:

{
"error": "missing or invalid Authorization header"
}

Best practices

  • Use fsk_test_ keys for development; never use fsk_live_ keys in test environments
  • Store keys in environment variables, not in code
  • Rotate keys periodically by creating new ones and revoking old ones
  • Use separate keys for different services or environments