1. Concepts
  2. API Keys

Each organization can have several API Keys, for example one for the sandbox and another for production.

​
How to generate one

There are two ways:

  • Together with the organization: in Create organization, send generateApiKey: true and apiKeyOptions. The key comes back in apiKey.
  • Later: use POST /enterprise/organizations/{organizationId}/api-keys. The key comes back at the root of the response.

In both cases the response includes:

FieldDescription
keyIdThe key ID.
rawKeyThe value for the x-api-key header.

The rawKey is shown only once. If it is lost, generate a new key.

​
Key options

{
  "name": "integracao-nfe-homolog",
  "scopes": "nfe:emit,nfe:read",
  "tpAmb": "HOMOLOGACAO",
  "expirationPreset": "1y"
}
FieldDescription
nameA name to identify the key.
scopesPermissions, comma-separated. See below.
tpAmbHOMOLOGACAO (sandbox) or PRODUCAO (production). The key only issues in the chosen environment.
expirationPresetValidity from creation. E.g. 1y (one year).

​
Scopes

ScopeAllows
nfe:emitIssuing NF-e and registering events
nfe:readQuerying NF-e and events
nfse:emitIssuing NFS-e
nfse:readQuerying NFS-e

Give each key only the scopes the integration needs.

​
Environment

The invoice’s environment comes from the API Key: a HOMOLOGACAO key issues in the sandbox and a PRODUCAO key in production. Do not send the environment in the payload.

Integrate and test with a HOMOLOGACAO key. Generate the PRODUCAO key only when you go live.