1. Inicio
  2. Documentos
  3. NS NFe (English)
  4. Utility Functions
  5. Generate XML

Generate XML

Through this endpoint, it’s possible to send an txt or json of an NF-e, which will be converted to an xml without the signature information.

URL

Production: POST https://nfe.ns.eti.br/util/generatexml

Input data

The input data of this method follows the NF-e issuance stantard, according to the data format.

Sending data in JSON format

To send data in JSON the request Content-Type must be defined as application/json. The token can be informed either in the body or in the request header.

FieldDescription
X-AUTH-TOKENUser access token
NFeNF-e data (according to Sefaz Contributors’ Guidance Manual)
Sending data in TXT format

To send data in TXT, the Content-Type of the request must be defined as text/plain;charset=urf-8 and the X-AUTH-TOKEN must be sent in the HTTP header.

When sending in TXT format, the request body must contain the TXT content with the NF-e information. This content must be generated from the TXT issuance layout by the local integrator of NS Tecnologia.

It’s also possible to issue using the layout of the public issuer. For that, just sent the TXT content in this layout and inform the header layout with the public value in the request headers.

Request examples

NF-e issuance request in JSON

curl -X POST 
    \-H "Content-Type: application/json" 
    \-H "X-AUTH-TOKEN: YOUR_TOKEN" 
    \-d '{"NFe":{...}}' \
    https://nfe.ns.eti.br/util/generatexml

NF-e issuance request in TXT

curl -X POST 
    \-H "X-AUTH-TOKEN: SEU_TOKEN" 
    \-H "Content-Type: text/plain" 
    \-d 'NOTA FISCAL|1| \A|3.10||'
    \https://nfe.ns.eti.br/util/generatexml
Returned data
FieldDescriptionNotes
statusProcessing status code
motivoProcessing status literal description
xmlXML generated from the jsonOnly when status = 200
Return examples

Successful return

{
    "status": 200,
    "motivo": "Xml gerado com sucesso",
    "xml": "<NFe xmlns=\"http://www.portalfiscal.inf.br/nfe\">....</NFe>"
}

Return with data error

{
    "status": -2,
    "motivo": "NFe invalido de acordo com a validacao contra schema",
    "erros": ["cvc-pattern-valid: Value '9618000' is not facet-valid with respect to pattern '[0-9]{8}' for type '#AnonType_CEPTEndereco'.","O campo 'CEP' foi preenchido incorretamente com o valor '9618000'. Este campo deve ser preenchido com numeros e conter exatamente 8 caracteres."]
}
Return codes
CodeDescription
200XML generated successfully
-2Information error according to data type. Check the "motivo" field to identify the incorrect fields
-3Non-existent validation schema for the NF-e version informed in NF/infNFe/versao
-4Data sent out of the expected startard. Check the "motivo" field for more information
Generate Cancellation XML

Through this endpoint, it’s possible to send a Cancellation json that will be converted to an xml without signature information.

URL

Production: POST https://nfe.ns.eti.br/util/generatecancel

Input data

The input data of this method is the same as Cancellation in the NS NF-e API.

FieldDescriptionOccurrenceNotes
X-AUTH-TOKENUser access token1-1
chNFeNF-e access key1-1
tpAmbNF-e authorization environment type:
1 - Production
2 - Homologation
1-1
dhEventoDate and time of the cancellation1-1Sefaz Standard: YYYY-MM-DDTHH:MM:SS+UTC
E.g.: 2016-06-13T15:04:10-02:00
nProtNF-e authorization protocol number1-1
xJustLiteral description of the reason for cancelling the NF-e
Request example

NF-e Cancellation request

curl -X POST 
    \-H "Content-Type: application/json" 
    \-d '{"X-AUTH-TOKEN": "YUOR_TOKEN", "chNFe": "43161107364617000135550000000099601000094832", "tpAmb": "2", "dhEvento": "2016-11-28T19:06:14-02:00", "nProt": "143160001510168", "xJust": "NF-e cancelada para teste de desenvolvimento de software de integração"}'
    \https://nfe.ns.eti.br/util/generatecancel
Returned data
FieldDescriptionNotes
statusProcessing status code
motivoProcessing status literal description
xmlXML generated from the jsonOnly when status = 200
Return example

Successful return

{
    "status": 200,
    "motivo": "Xml gerado com sucesso",
    "xml": "<evento versao=\"1.00\" xmlns=\"http://www.portalfiscal.inf.br/nfe\" >....</evento>"
}
Return code
CodeDescription
200XML generated successfully
-2Invalid access key: CHAVE. The key must 44 numeric characters
Generate Correction Letter XML

Through this endpoint, it’s possible to send a Correction Letter json that will be converted to an xml without signature information.

URL

Production: POST https://nfe.ns.eti.br/util/generatecce

Input data

The input data of this method is the same as Correction Letter in the NS NF-e API.

FieldDescriptionOccurrenceNotes
X-AUTH-TOKENUser access token1-1
chNFeNF-e access key1-1
tpAmbNF-e authorization environment type:
1 - Production
2 - Homologation
1-1
dhEventoDate and time of the correction1-1Sefaz Standard: YYYY-MM-DDTHH:MM:SS+UTC. E.g.: 2016-06-13T15:04:10-02:00
nSeqEventoEvent sequential number1-1Sequential of the event for the same type of event
The event author must number sequentially
xCorrecaoCorrection description to be carried out in the NF-e1-1E.g.: "VALIDADE DA LICENCA DE 01/09/2015 A 01/09/2016.".
Sefaz won't accept correction letters in english.
Translation: "License validity from DD/MM/YYYY to DD/MM/YYYY.".
Request example

NF-e CCe request

curl -X POST 
    \-H "Content-Type: application/json" 
    \-d '{"X-AUTH-TOKEN": "YOUR_TOKEN", "chNFe": "43161107364617000135550000000099461000094833", "tpAmb": "2", "dhEvento": "2016-11-28T19:06:14-02:00", "nSeqEvento": "1", "xCorrecao": "CC-e realizada para teste de integração"}'
    \https://nfe.ns.eti.br/util/generatecce
Returned data
FieldDescriptionNotes
statusProcessing status code
motivoProcessing status literal description
xmlXML generated from the jsonOnly when status = 200
Return example
{
    "status": 200,
    "motivo": "Xml gerado com sucesso",
    "xml": "<evento versao=\"1.00\" xmlns=\"http://www.portalfiscal.inf.br/nfe\" >....</evento>"
}
Return codes
CodeDescription
200XML generated successfully
-2Invalid access key: CHAVE. The key must 44 numeric characters
Generate Disablement XML

Through this endpoint, it’s possible to send a Disablement json that will be converted to an xml without signature information.

URL

Production: POST https://nfe.ns.eti.br/util/generateinut

Input data

The input data of this method is the same as Disable Numeration in the NS NF-e API.

FieldDescriptionOccurrenceNotes
X-AUTH-TOKENUser access token1-1
chNFeNF-e access key1-1
tpAmbNF-e authorization environment type:
1 - Production
2 - Homologation
1-1
dhEventoDate and time of the correction1-1Sefaz Standard: YYYY-MM-DDTHH:MM:SS+UTC. E.g.: 2016-06-13T15:04:10-02:00
nSeqEventoEvent sequential number1-1Sequential of the event for the same type of event
The event author must number sequentially
xCorrecaoCorrection description to be carried out in the NF-e1-1E.g.: "VALIDADE DA LICENCA DE 01/09/2015 A 01/09/2016.".
Sefaz won't accept correction letters in english.
Translation: "License validity from DD/MM/YYYY to DD/MM/YYYY.".
Request example

NF-e Disablement request

curl -X POST 
    \-H "Content-Type: application/json" 
    \-d '{"X-AUTH-TOKEN": "YOUR_TOKEN", "cUF": "43", "tpAmb": "2", "ano": "16", "CNPJ": "07364617000135", "serie": "0", "nNFIni": "9996", "nNFFin": "9996", "xJust": "Inutilizacao realizada para teste de integracao"}'
    \https://nfe.ns.eti.br/util/generateinut
Returned data
FieldDescriptionNotes
statusProcessing status code
motivoProcessing status literal description
xmlXML generated from the jsonOnly when status = 200
Return example

Successful return

{
    "status": 200,
    "motivo": "Xml gerado com sucesso",
    "xml": "<inutNFe versao=\"4.00\" xmlns=\"http://www.portalfiscal.inf.br/nfe\" >....</inutNFe>"
}
Return codes
CodeDescription
200XML generated successfully

Como podemos ajudar?