TF Fiscal

Platform & integrations

SSO

2 endpoints

Base URL (Production)
https://api.tffiscal.com
Authentication
Headers: sign, timestamp, token
Ticket Validity
60 seconds — single use

SSO (Single Sign-On) allows your ERP to generate a direct access link to TFiscal for the user, already authenticated in the corresponding company and in the desired language — without requiring them to enter credentials.

How it works:
  • The ERP calls POST /api/sso/create_ticket sending the company token.
  • TFiscal returns a redirectUrl containing a single-use opaque ticket.
  • The ERP redirects the user's browser to that URL.
  • The page consumes the ticket and the user logs in automatically on the company panel.
⚠️ Security: the actual company token never appears in the URL. Only the ephemeral ticket (valid for 60 seconds and single use) is exposed to the browser.
POST/api/sso/create_ticket

Generate automatic login link

Generates a single-use ticket that can be used within 60 seconds to automatically log the user into the company panel matching the token.

Required Headers

HeaderTypeDescription
tokenstringCompany token (same as used to issue NF-e)
signstringMD5 signature: MD5(token + path + body + timestamp)
timestampstringUnix timestamp in seconds (5-minute window)

Fields

FieldRequiredTypeDescription
tokenYesstringCompany token (w_company.token) — same one used in /api/invoice/create
languageNostringUI language: br, en, zh, es, ja, ko. Default: br
pageNostringLanding page after login. Accepted values: emitir_nfe. Empty or missing opens the default panel (/company/kanban).

Response Fields

FieldTypeDescription
successbooleantrue when the ticket was successfully generated
ticketstringOpaque ticket (random, 32 bytes base64url)
redirectUrlstringFull URL where the ERP should redirect the user's browser
expiresInSecondsnumberValidity in seconds (always 60)
expiresAtstringUTC expiration date/time (ISO 8601)

Error Responses

MessageCause
Token is requiredThe token field was not sent in the body
Invalid tokenToken does not match any registered company
This token is linked to multiple companies. Send the specific company token you want to access.Integrator token with more than one company — send the specific company token
Rate limit exceededMore than 30 calls per minute for the same token
POST/api/sso/consume_ticket

Consume SSO ticket

Exchanges the ticket generated by /api/sso/create_ticket for the TFiscal session JWT. This endpoint is called by the frontend (route /sso) and does not require sign/timestamp headers — the opaque ticket itself is the credential. Each ticket can be consumed only once and expires in 60 seconds.

Body

FieldTypeDescription
ticket *stringTicket returned by create_ticket

* Required field.

Response fields

FieldTypeDescription
access_tokenstringSession JWT (365-day validity). Use in the Authorization header of TFiscal calls
typestringUser type (user, admin, etc.)
uidintInternal user ID
company_idintID of the company selected in create_ticket
languagestringLanguage chosen in create_ticket (always normalized)
pagestringTarget page (or empty string if not set)

Error responses

MessageCause
Ticket inválidoBody without ticket field
Ticket inválido ou expiradoTicket does not exist, has already been consumed, or is past the 60-second limit
Rate limit exceededMore than 60 consumes per minute from the same IP
Sessão inválidaThe user linked to the ticket no longer exists

Ticket characteristics

CharacteristicValue
Validity60 seconds after generation
UsageSingle use — once consumed, cannot be reused
Rate limit30 tickets/minute per token · 60 consumptions/minute per IP
StorageMongoDB with automatic TTL — expired tickets are removed

Navigation restrictions

Users logged in via SSO have access only to the corresponding company screens (/invoice/company/*). Attempts to access other areas (reseller panels, general reports, administration) are automatically redirected to the company panel.

Session after login

After exchanging the ticket for a JWT, the user has a normal TFiscal session (JWT valid for 365 days, same as traditional login). The 60 seconds are only the window between generating the ticket and opening the link — afterwards the user remains logged in normally until they sign out.

⚠️ Important: the create_ticket must be called exclusively server-side by the ERP. Never call this endpoint directly from the browser — that would expose the company token in the front-end.