E-Invoice management
When you need to deal with an e-invoice, we provide a handful of methods that you can use to fulfill your needs: you can verify the XML of your e-invoice, download it, send it to the SDI and eventually obtain the rejection reason.
In this guide, we suppose you already created your e-invoice in Fatture in Cloud, and you just need to send it to the SDI. If this is not the case, please check this guide to create your first invoice.
Unfortunately, no. Fatture in Cloud lets you send documents to the SDI only if they were created through the Fatture in Cloud functionalities, so if you have an XML you can't just send it to the SDI using our APIs. Please, check this guide for a more detailed explanation.
🔍 Verify the E-Invoice XML
With the Verify e-invoice XML method, you can verify your e-invoice XML before sending it to the SDI. If your XML contains an error or it is missing some fields, you can patch it by editing the invoice. A list of the most common validation errors can be found here.
Below you can find an example of a failed XML verification:
{
"error": {
"message": "Validation XML",
"validation_result": [
"Nei dati generali del documento, il contenuto \"0000-00-00\" del campo Data non è nel formato valido"
]
}
}
The corresponding code with our SDKs:
- C#
- Go
- Java
- JavaScript
- PHP
- Python
- Ruby
- TypeScript
public class VerifyEInvoiceExample {
public static void Main() {
Configuration config = new Configuration();
config.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new IssuedEInvoicesApi(config);
var companyId = 12345; // int | The ID of the company.
var documentId = 56; // int | The ID of the document.
try {
// Verify E-Invoice XML
VerifyEInvoiceXmlResponse result = apiInstance.VerifyEInvoiceXml(companyId, documentId);
Console.WriteLine(result);
}
catch (ApiException e) {
Console.WriteLine("Exception when calling IssuedEInvoicesApi.VerifyEInvoiceXml: " + e.Message);
Console.WriteLine("Status Code: " + e.ErrorCode);
Console.WriteLine(e.StackTrace);
}
}
}
func VerifyEInvoiceExample() {
companyId := int32(12345) // int32 | The ID of the company.
documentId := int32(56) // int32 | The ID of the document.
auth := context.WithValue(context.Background(), fattureincloudapi.ContextAccessToken, "ACCESS_TOKEN")
configuration := fattureincloudapi.NewConfiguration()
apiClient := fattureincloudapi.NewAPIClient(configuration)
resp, r, err := apiClient.IssuedEInvoicesAPI.VerifyEInvoiceXml(auth, companyId, documentId).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `IssuedEInvoicesAPI.VerifyEInvoiceXml``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `VerifyEInvoiceXml`: VerifyEInvoiceXmlResponse
json.NewEncoder(os.Stdout).Encode(resp)
}
public class VerifyEInvoiceExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: OAuth2AuthenticationCodeFlow
OAuth OAuth2AuthenticationCodeFlow = (OAuth) defaultClient.getAuthentication("OAuth2AuthenticationCodeFlow");
OAuth2AuthenticationCodeFlow.setAccessToken("YOUR ACCESS TOKEN");
IssuedEInvoicesApi apiInstance = new IssuedEInvoicesApi(defaultClient);
Integer companyId = 12345; // Integer | The ID of the company.
Integer documentId = 56; // Integer | The ID of the document.
try {
VerifyEInvoiceXmlResponse result = apiInstance.verifyEInvoiceXml(companyId, documentId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling IssuedEInvoicesApi#verifyEInvoiceXml");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
let defaultClient = fattureInCloudSdk.ApiClient.instance;
let OAuth2AuthenticationCodeFlow =
defaultClient.authentications["OAuth2AuthenticationCodeFlow"];
OAuth2AuthenticationCodeFlow.accessToken = "YOUR ACCESS TOKEN";
let apiInstance = new fattureInCloudSdk.IssuedEInvoicesApi();
let companyId = 12345; // Number | The ID of the company.
let documentId = 56; // Number | The ID of the document.
apiInstance.verifyEInvoiceXml(companyId, documentId).then(
(result) => {
console.log(
"API called successfully. Returned result: " + JSON.stringify(result)
);
},
(error) => {
console.error(error);
}
);
$config = FattureInCloud\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new FattureInCloud\Api\IssuedEInvoicesApi(
new GuzzleHttp\Client(),
$config
);
$company_id = 12345; // int | The ID of the company.
$document_id = 56; // int | The ID of the document.
try {
$result = $apiInstance->verifyEInvoiceXml($company_id, $document_id);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling IssuedEInvoicesApi->verifyEInvoiceXml: ', $e->getMessage(), PHP_EOL;
}
configuration = fattureincloud_python_sdk.Configuration()
configuration.access_token = os.environ["ACCESS_TOKEN"]
# Enter a context with an instance of the API client
with fattureincloud_python_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = fattureincloud_python_sdk.IssuedEInvoicesApi(api_client)
company_id = 12345 # int | The ID of the company.
document_id = 56 # int | The ID of the document.
try:
# Verify E-Invoice XML
api_response = api_instance.verify_e_invoice_xml(company_id, document_id)
print("The response of IssuedEInvoicesApi->verify_e_invoice_xml:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling IssuedEInvoicesApi->verify_e_invoice_xml: %s\n" % e)
FattureInCloud_Ruby_Sdk.configure do |config|
config.access_token = 'YOUR ACCESS TOKEN'
end
api_instance = FattureInCloud_Ruby_Sdk::IssuedEInvoicesApi.new
company_id = 12345 # Integer | The ID of the company.
document_id = 56 # Integer | The ID of the document.
begin
# Verify E-Invoice XML
result = api_instance.verify_e_invoice_xml(company_id, document_id)
p result
rescue FattureInCloud_Ruby_Sdk::ApiError => e
puts "Error when calling IssuedEInvoicesApi->verify_e_invoice_xml: #{e}"
end
const apiConfig = new Configuration({
accessToken: "YOUR ACCESS TOKEN",
});
let apiInstance = new IssuedEInvoicesApi(apiConfig);
let companyId = 12345; // Number | The ID of the company.
let documentId = 56; // Number | The ID of the document.
apiInstance.verifyEInvoiceXml(companyId, documentId).then(
(data) => {
console.log("API called successfully. Returned data: " + data);
},
(error) => {
console.error(error);
}
);
⬇️ Download the E-Invoice XML
With the Get e-invoice XML method you can download your e-invoice XML if you need to.
HTTP/1.1 200 OK
Content-Type: text/xml;charset=UTF-8
<p:FatturaElettronica xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:p="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" versione="FPR12">
<FatturaElettronicaHeader>
...
</FatturaElettronicaHeader>
<FatturaElettronicaBody>
...
</FatturaElettronicaBody>
</p:FatturaElettronica>
The corresponding code with our SDKs:
- C#
- Go
- Java
- JavaScript
- PHP
- Python
- Ruby
- TypeScript
public class GetEInvoiceExample {
public static void Main() {
Configuration config = new Configuration();
config.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new IssuedEInvoicesApi(config);
var companyId = 12345; // int | The ID of the company.
var documentId = 56; // int | The ID of the document.
var includeAttachment = true; // bool? | Include the attachment to the XML e-invoice. (optional)
try {
// Get E-Invoice XML
string result = apiInstance.GetEInvoiceXml(companyId, documentId, includeAttachment);
Console.WriteLine(result);
}
catch (ApiException e) {
Console.WriteLine("Exception when calling IssuedEInvoicesApi.GetEInvoiceXml: " + e.Message);
Console.WriteLine("Status Code: " + e.ErrorCode);
Console.WriteLine(e.StackTrace);
}
}
}
func GetEInvoiceExample() {
companyId := int32(12345) // int32 | The ID of the company.
documentId := int32(56) // int32 | The ID of the document.
includeAttachment := true // bool | Include the attachment to the XML e-invoice. (optional)
auth := context.WithValue(context.Background(), fattureincloudapi.ContextAccessToken, "ACCESS_TOKEN")
configuration := fattureincloudapi.NewConfiguration()
apiClient := fattureincloudapi.NewAPIClient(configuration)
resp, r, err := apiClient.IssuedEInvoicesAPI.GetEInvoiceXml(auth, companyId, documentId).IncludeAttachment(includeAttachment).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `IssuedEInvoicesAPI.GetEInvoiceXml``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `GetEInvoiceXml`: string
json.NewEncoder(os.Stdout).Encode(resp)
}
public class GetEInvoiceExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
OAuth OAuth2AuthenticationCodeFlow = (OAuth) defaultClient.getAuthentication("OAuth2AuthenticationCodeFlow");
OAuth2AuthenticationCodeFlow.setAccessToken("YOUR ACCESS TOKEN");
IssuedEInvoicesApi apiInstance = new IssuedEInvoicesApi(defaultClient);
Integer companyId = 12345; // Integer | The ID of the company.
Integer documentId = 56; // Integer | The ID of the document.
Boolean includeAttachment = true; // Boolean | Include the attachment to the XML e-invoice.
try {
String result = apiInstance.getEInvoiceXml(companyId, documentId, includeAttachment);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling IssuedEInvoicesApi#getEInvoiceXml");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
let defaultClient = fattureInCloudSdk.ApiClient.instance;
let OAuth2AuthenticationCodeFlow =
defaultClient.authentications["OAuth2AuthenticationCodeFlow"];
OAuth2AuthenticationCodeFlow.accessToken = "YOUR ACCESS TOKEN";
let apiInstance = new fattureInCloudSdk.IssuedEInvoicesApi();
let companyId = 12345; // Number | The ID of the company.
let documentId = 56; // Number | The ID of the document.
let opts = {
includeAttachment: true, // Boolean | Include the attachment to the XML e-invoice.
};
apiInstance.getEInvoiceXml(companyId, documentId, opts).then(
(result) => {
console.log(
"API called successfully. Returned result: " + JSON.stringify(result)
);
},
(error) => {
console.error(error);
}
);
$config = FattureInCloud\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new FattureInCloud\Api\IssuedEInvoicesApi(
new GuzzleHttp\Client(),
$config
);
$company_id = 12345; // int | The ID of the company.
$document_id = 56; // int | The ID of the document.
$include_attachment = True; // bool | Include the attachment to the XML e-invoice.
try {
$result = $apiInstance->getEInvoiceXml($company_id, $document_id, $include_attachment);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling IssuedEInvoicesApi->getEInvoiceXml: ', $e->getMessage(), PHP_EOL;
}
configuration = fattureincloud_python_sdk.Configuration()
configuration.access_token = os.environ["ACCESS_TOKEN"]
# Enter a context with an instance of the API client
with fattureincloud_python_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = fattureincloud_python_sdk.IssuedEInvoicesApi(api_client)
company_id = 12345 # int | The ID of the company.
document_id = 56 # int | The ID of the document.
include_attachment = True # bool | Include the attachment to the XML e-invoice. (optional)
try:
# Get E-Invoice XML
api_response = api_instance.get_e_invoice_xml(company_id, document_id, include_attachment=include_attachment)
print("The response of IssuedEInvoicesApi->get_e_invoice_xml:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling IssuedEInvoicesApi->get_e_invoice_xml: %s\n" % e)
FattureInCloud_Ruby_Sdk.configure do |config|
config.access_token = 'YOUR ACCESS TOKEN'
end
api_instance = FattureInCloud_Ruby_Sdk::IssuedEInvoicesApi.new
company_id = 12345 # Integer | The ID of the company.
document_id = 56 # Integer | The ID of the document.
opts = {
include_attachment: true # Boolean | Include the attachment to the XML e-invoice.
}
begin
# Get E-Invoice XML
result = api_instance.get_e_invoice_xml(company_id, document_id, opts)
p result
rescue FattureInCloud_Ruby_Sdk::ApiError => e
puts "Error when calling IssuedEInvoicesApi->get_e_invoice_xml: #{e}"
end
const apiConfig = new Configuration({
accessToken: "YOUR ACCESS TOKEN",
});
let apiInstance = new IssuedEInvoicesApi(apiConfig);
let companyId = 12345; // Number | The ID of the company.
let documentId = 56; // Number | The ID of the document.
let includeAttachment = true; // Boolean | Include the attachment to the XML e-invoice.
apiInstance.getEInvoiceXml(companyId, documentId, includeAttachment).then(
(data) => {
console.log("API called successfully. Returned data: " + data);
},
(error) => {
console.error(error);
}
);
📬 Send the E-Invoice
If your e-invoice XML is valid you can now send it to the SDI using the Send e-invoice method.
The corresponding code with our SDKs:
- C#
- Go
- Java
- JavaScript
- PHP
- Python
- Ruby
- TypeScript
public class SendEInvoiceExample {
public static void Main() {
Configuration config = new Configuration();
config.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new IssuedEInvoicesApi(config);
var companyId = 12345; // int | The ID of the company.
var documentId = 56; // int | The ID of the document.
// Optional parameter used to test without actually sending the invoice to the SDI
var send_options = new SendEInvoiceRequestOptions(true); //set 'dry_run' true
var sendEInvoiceRequest = new SendEInvoiceRequest(default,send_options); // SendEInvoiceRequest | (optional)
try {
// Send E-Invoice
SendEInvoiceResponse result = apiInstance.SendEInvoice(companyId, documentId, sendEInvoiceRequest);
Console.WriteLine(result);
}
catch (ApiException e) {
Console.WriteLine("Exception when calling IssuedEInvoicesApi.SendEInvoice: " + e.Message);
Console.WriteLine("Status Code: " + e.ErrorCode);
Console.WriteLine(e.StackTrace);
}
}
}
func SendEInvoiceExample() {
companyId := int32(12345) // int32 | The ID of the company.
documentId := int32(56) // int32 | The ID of the document.
sendEInvoiceRequest := *fattureincloud.NewSendEInvoiceRequest() // SendEInvoiceRequest | (optional)
auth := context.WithValue(context.Background(), fattureincloudapi.ContextAccessToken, "ACCESS_TOKEN")
configuration := fattureincloudapi.NewConfiguration()
apiClient := fattureincloudapi.NewAPIClient(configuration)
// Optional parameter used to test without actually sending the invoice to the SDI
options := fattureincloud.NewSendEInvoiceRequestOptions().SetDryRun(true)
sendEInvoiceRequest.SetOptions(*options)
resp, r, err := apiClient.IssuedEInvoicesAPI.SendEInvoice(auth, companyId, documentId).SendEInvoiceRequest(sendEInvoiceRequest).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `IssuedEInvoicesAPI.SendEInvoice``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `SendEInvoice`: SendEInvoiceResponse
json.NewEncoder(os.Stdout).Encode(resp)
}
public class SendEInvoiceExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
OAuth OAuth2AuthenticationCodeFlow = (OAuth) defaultClient.getAuthentication("OAuth2AuthenticationCodeFlow");
OAuth2AuthenticationCodeFlow.setAccessToken("YOUR ACCESS TOKEN");
IssuedEInvoicesApi apiInstance = new IssuedEInvoicesApi(defaultClient);
Integer companyId = 12345; // Integer | The ID of the company.
Integer documentId = 56; // Integer | The ID of the document.
SendEInvoiceRequest sendEInvoiceRequest = new SendEInvoiceRequest(); // SendEInvoiceRequest |
// Optional parameter used to test without actually sending the invoice to the SDI
SendEInvoiceRequestOptions options = new SendEInvoiceRequestOptions();
options.setDryRun(true);
sendEInvoiceRequest.setOptions(options);
try {
SendEInvoiceResponse result = apiInstance.sendEInvoice(companyId, documentId, sendEInvoiceRequest);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling IssuedEInvoicesApi#sendEInvoice");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
let OAuth2AuthenticationCodeFlow =
defaultClient.authentications["OAuth2AuthenticationCodeFlow"];
OAuth2AuthenticationCodeFlow.accessToken = "YOUR ACCESS TOKEN";
let apiInstance = new fattureInCloudSdk.IssuedEInvoicesApi();
let companyId = 12345; // Number | The ID of the company.
let documentId = 56; // Number | The ID of the document.
let opts = {
sendEInvoiceRequest: {
data: { withholding_tax_causal: "causale" },
options: { dry_run: true }, // Optional parameter used to test without actually sending the invoice to the SDI
}, // SendEInvoiceRequest |
};
apiInstance.sendEInvoice(companyId, documentId, opts).then(
(result) => {
console.log(
"API called successfully. Returned result: " + JSON.stringify(result)
);
},
(error) => {
console.error(error);
}
);
$config = FattureInCloud\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new FattureInCloud\Api\IssuedEInvoicesApi(
new GuzzleHttp\Client(),
$config
);
$company_id = 12345; // int | The ID of the company.
$document_id = 56; // int | The ID of the document.
$send_e_invoice_request = new \FattureInCloud\Model\SendEInvoiceRequest; // \FattureInCloud\Model\SendEInvoiceRequest |
// Optional parameter used to test without actually sending the invoice to the SDI
$send_options = new \FattureInCloud\Model\SendEInvoiceRequestOptions(['dry_run' => true]);
$send_e_invoice_request->setOptions($send_options);
try {
$result = $apiInstance->sendEInvoice($company_id, $document_id, $send_e_invoice_request);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling IssuedEInvoicesApi->sendEInvoice: ', $e->getMessage(), PHP_EOL;
}
configuration = fattureincloud_python_sdk.Configuration()
configuration.access_token = os.environ["ACCESS_TOKEN"]
# Enter a context with an instance of the API client
with fattureincloud_python_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = fattureincloud_python_sdk.IssuedEInvoicesApi(api_client)
company_id = 12345 # int | The ID of the company.
document_id = 56 # int | The ID of the document.
send_e_invoice_request = {
"data":{"withholding_tax_causal":"causale"},
"options":{"dry_run":True} # Optional parameter used to test without actually sending the invoice to the SDI
} # SendEInvoiceRequest | (optional)
try:
# Send E-Invoice
api_response = api_instance.send_e_invoice(company_id, document_id, send_e_invoice_request=send_e_invoice_request)
print("The response of IssuedEInvoicesApi->send_e_invoice:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling IssuedEInvoicesApi->send_e_invoice: %s\n" % e)
FattureInCloud_Ruby_Sdk.configure do |config|
config.access_token = 'YOUR ACCESS TOKEN'
end
api_instance = FattureInCloud_Ruby_Sdk::IssuedEInvoicesApi.new
company_id = 12345 # Integer | The ID of the company.
document_id = 56 # Integer | The ID of the document.
# Optional parameter used to test without actually sending the invoice to the SDI
options = FattureInCloud_Ruby_Sdk::SendEInvoiceRequestOptions.new(dry_run: true)
opts = {
send_e_invoice_request: FattureInCloud_Ruby_Sdk::SendEInvoiceRequest.new(options: options) # SendEInvoiceRequest |
}
begin
# Send E-Invoice
result = api_instance.send_e_invoice(company_id, document_id, opts)
p result
rescue FattureInCloud_Ruby_Sdk::ApiError => e
puts "Error when calling IssuedEInvoicesApi->send_e_invoice: #{e}"
end
const apiConfig = new Configuration({
accessToken: "YOUR ACCESS TOKEN",
});
let apiInstance = new IssuedEInvoicesApi(apiConfig);
let companyId = 12345; // Number | The ID of the company.
let documentId = 56; // Number | The ID of the document.
let sendEInvoiceRequest: SendEInvoiceRequest = {
data: { withholding_tax_causal: "causale" },
options: { dry_run: true }, // Optional parameter used to test without actually sending the invoice to the SDI
}; // SendEInvoiceRequest |
apiInstance.sendEInvoice(companyId, documentId, sendEInvoiceRequest).then(
(data) => {
console.log("API called successfully. Returned data: " + data);
},
(error) => {
console.error(error);
}
);
After the invoice has been sent, you can check its status as stated in the following section.
🏴☠️ The Dry-Run Flag
If you are developing an integration and you want to test the Send e-invoice method without actually sending the invoice to the SDI we offer a proper field for this purpose, the options.dry_run flag.
{
"data": {
...
},
"options": {
"dry_run": true
}
}
The flag is optional, and the default is false; if you use it and you set it as true, all the e-invoice checks will be run but the actual dispatch.
To use the options.dry_run flag, e-invoicing must be active for your account, even if the invoice will not be sent to the SDI.
👮 Check the E-Invoice status
After the invoice has been sent, you can check its status by making a Get Issued Document request: the ei_status field will contain the status of your e-invoice.
To show the ei_status field, you need to customize the response, selecting the detailed fieldset or including it in the fields list.
The corresponding code with our SDKs:
- C#
- Go
- Java
- JavaScript
- PHP
- Python
- Ruby
- TypeScript
public class GetIssuedDocumentExample
{
public static void Main()
{
Configuration config = new Configuration();
// Configure OAuth2 access token for authorization: OAuth2AuthenticationCodeFlow
config.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new IssuedDocumentsApi(config);
var companyId = 12345; // int | The ID of the company.
var documentId = 56; // int | The ID of the document.
var fields = "fields_example; // string | List of comma-separated fields. (optional)
var fieldset = "detailed"; // This must be used to retrieve the ei_status field
try
{
// Get Issued Document
GetIssuedDocumentResponse result = apiInstance.GetIssuedDocument(companyId, documentId, fields, fieldset);
Console.WriteLine(result);
}
catch (ApiException e)
{
Console.WriteLine("Exception when calling IssuedDocumentsApi.GetIssuedDocument: " + e.Message);
Console.WriteLine("Status Code: " + e.ErrorCode);
Console.WriteLine(e.StackTrace);
}
}
}
func GetIssuedDocumentExample() {
companyId := int32(12345) // int32 | The ID of the company.
documentId := int32(56) // int32 | The ID of the document.
fields := "fields_example" // string | List of comma-separated fields. (optional)
fieldset := "detailed" // This is required to retrieve the ei_status field
auth := context.WithValue(context.Background(), fattureincloudapi.ContextAccessToken, "ACCESS_TOKEN")
configuration := fattureincloudapi.NewConfiguration()
apiClient := fattureincloudapi.NewAPIClient(configuration)
resp, r, err := apiClient.IssuedDocumentsAPI.GetIssuedDocument(auth, companyId, documentId).Fields(fields).Fieldset(fieldset).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `IssuedDocumentsAPI.GetIssuedDocument``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `GetIssuedDocument`: GetIssuedDocumentResponse
json.NewEncoder(os.Stdout).Encode(resp)
}
public class GetIssuedDocumentExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: OAuth2AuthenticationCodeFlow
OAuth OAuth2AuthenticationCodeFlow = (OAuth) defaultClient.getAuthentication("OAuth2AuthenticationCodeFlow");
OAuth2AuthenticationCodeFlow.setAccessToken("YOUR ACCESS TOKEN");
IssuedDocumentsApi apiInstance = new IssuedDocumentsApi(defaultClient);
Integer companyId = 12345; // Integer | The ID of the company.
Integer documentId = 56; // Integer | The ID of the document.
String fields = "fields_example"; // String | List of comma-separated fields.
String fieldset = "detailed"; // This is required to retrieve the ei_status field
try {
GetIssuedDocumentResponse result = apiInstance.getIssuedDocument(companyId, documentId, fields, fieldset);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling IssuedDocumentsApi#getIssuedDocument");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
// Configure OAuth2 access token for authorization: OAuth2AuthenticationCodeFlow
let OAuth2AuthenticationCodeFlow =
defaultClient.authentications["OAuth2AuthenticationCodeFlow"];
OAuth2AuthenticationCodeFlow.accessToken = "YOUR ACCESS TOKEN";
let apiInstance = new fattureInCloudSdk.IssuedDocumentsApi();
let companyId = 12345; // Number | The ID of the company.
let documentId = 56; // Number | The ID of the document.
let opts = {
fields: "fields_example", // String | List of comma-separated fields.
fieldset: "detailed", // This is required to retrieve the ei_status field
};
apiInstance.getIssuedDocument(companyId, documentId, opts).then(
(result) => {
console.log(
"API called successfully. Returned result: " + JSON.stringify(result)
);
},
(error) => {
console.error(error);
}
);
// Configure OAuth2 access token for authorization: OAuth2AuthenticationCodeFlow
$config = FattureInCloud\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new FattureInCloud\Api\IssuedDocumentsApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$company_id = 12345; // int | The ID of the company.
$document_id = 56; // int | The ID of the document.
$fields = 'fields_example'; // string | List of comma-separated fields.
$fieldset = 'detailed'; // This is required to retrieve the ei_status field
try {
$result = $apiInstance->getIssuedDocument($company_id, $document_id, $fields, $fieldset);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling IssuedDocumentsApi->getIssuedDocument: ', $e->getMessage(), PHP_EOL;
}
configuration.access_token = os.environ["ACCESS_TOKEN"]
# Enter a context with an instance of the API client
with fattureincloud_python_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = fattureincloud_python_sdk.IssuedDocumentsApi(api_client)
company_id = 12345 # int | The ID of the company.
document_id = 56 # int | The ID of the document.
fields = 'fields_example' # str | List of comma-separated fields. (optional)
fieldset = 'detailed' # This is required to retrieve the ei_status field
try:
# Get Issued Document
api_response = api_instance.get_issued_document(company_id, document_id, fields=fields, fieldset=fieldset)
print("The response of IssuedDocumentsApi->get_issued_document:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling IssuedDocumentsApi->get_issued_document: %s\n" % e)
FattureInCloud_Ruby_Sdk.configure do |config|
# Configure OAuth2 access token for authorization: OAuth2AuthenticationCodeFlow
config.access_token = 'YOUR ACCESS TOKEN'
end
api_instance = FattureInCloud_Ruby_Sdk::IssuedDocumentsApi.new
company_id = 12345 # Integer | The ID of the company.
document_id = 56 # Integer | The ID of the document.
opts = {
fields: 'fields_example', # String | List of comma-separated fields.
fieldset: 'detailed' # This is required to retrieve the ei_status field
}
begin
# Get Issued Document
result = api_instance.get_issued_document(company_id, document_id, opts)
p result
rescue FattureInCloud_Ruby_Sdk::ApiError => e
puts "Error when calling IssuedDocumentsApi->get_issued_document: #{e}"
end
// Configure OAuth2 access token for authorization:
const apiConfig = new Configuration({
accessToken: "YOUR ACCESS TOKEN"
});
let apiInstance = new IssuedDocumentsApi(apiConfig);
let companyId = 12345; // Number | The ID of the company.
let documentId = 56; // Number | The ID of the document.
let fields = "fields_example", // String | List of comma-separated fields.
let fieldset = "detailed" // This is required to retrieve the ei_status field
apiInstance.getIssuedDocument(companyId, documentId, fieldset).then((data) => {
console.log('API called successfully. Returned data: ' + data);
}, (error) => {
console.error(error);
});
🚀 Real time updates!
If you want to keep the e-invoice status updated on your application, you can use our Webhooks to be notified when a status change occurs.
The Notification Type required to be notified
is the following: it.fattureincloud.webhooks.issued_documents.e_invoices.status_update
Please, note that the notification will not contain the status of the e-invoice, but just the ID of the updated document: you still need to use the Get Issued Document method to retrieve the status, but the webhooks will enable you to avoid wasting API quotas by performing polling operations.
The steps required to update the e-invoice status using Subscriptions are the following (you can find more details on the Webhooks page):
- (*) Require the Webhooks enablement by filling out the dedicated Google Form and waiting for the approval email
- (*) Create a target endpoint to manage the incoming notifications (check out the Notifications page); to be able to successfully create a subscription we suggest starting with the Verification type
- (*) Use the Create a Webhook Subscription method to require a new subscription
- (*) When you receive the Verification Notification, verify your subscription as described in the Subscriptions
- When an e-invoice status is updated, you'll receive the related Event Notification, containing the ID of the document involved
- Perform the Get Issued Document API request using the document's ID as input, and read the ei_status field
Note: All the steps starting with (*) must be performed only once to create the subscription, while all the other steps must be performed each time a new Notification is received by your endpoint.
🚨 Get the E-Invoice rejection reason
If your e-invoice gets rejected by the SDI, you can check the rejection reason with the Get rejection reason method. The list of the most common rejection reasons can be found here.
For example, you could get an error like the following one:
{
"data": {
"reason": "Il Codice Fiscale del cliente risulta sbagliato.",
"code": "0036",
"date": "2022-02-22"
}
}
The corresponding code with our SDKs:
- C#
- Go
- Java
- JavaScript
- PHP
- Python
- Ruby
- TypeScript
public class GetEInvoiceRejectionReasonExample {
public static void Main() {
Configuration config = new Configuration();
config.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new IssuedEInvoicesApi(config);
var companyId = 12345; // int | The ID of the company.
var documentId = 56; // int | The ID of the document.
try {
// Get E-Invoice Rejection Reason
GetEInvoiceRejectionReasonResponse result = apiInstance.GetEInvoiceRejectionReason(companyId, documentId);
Console.WriteLine(result);
}
catch (ApiException e) {
Console.WriteLine("Exception when calling IssuedEInvoicesApi.GetEInvoiceRejectionReason: " + e.Message);
Console.WriteLine("Status Code: " + e.ErrorCode);
Console.WriteLine(e.StackTrace);
}
}
}
func GetEInvoiceRejectionReasonExample() {
companyId := int32(12345) // int32 | The ID of the company.
documentId := int32(56) // int32 | The ID of the document.
auth := context.WithValue(context.Background(), fattureincloudapi.ContextAccessToken, "ACCESS_TOKEN")
configuration := fattureincloudapi.NewConfiguration()
apiClient := fattureincloudapi.NewAPIClient(configuration)
resp, r, err := apiClient.IssuedEInvoicesAPI.GetEInvoiceRejectionReason(auth, companyId, documentId).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `IssuedEInvoicesAPI.GetEInvoiceRejectionReason``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `GetEInvoiceRejectionReason`: GetEInvoiceRejectionReasonResponse
json.NewEncoder(os.Stdout).Encode(resp)
}
public class GetEInvoiceRejectionReasonExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
OAuth OAuth2AuthenticationCodeFlow = (OAuth) defaultClient.getAuthentication("OAuth2AuthenticationCodeFlow");
OAuth2AuthenticationCodeFlow.setAccessToken("YOUR ACCESS TOKEN");
IssuedEInvoicesApi apiInstance = new IssuedEInvoicesApi(defaultClient);
Integer companyId = 12345; // Integer | The ID of the company.
Integer documentId = 56; // Integer | The ID of the document.
try {
GetEInvoiceRejectionReasonResponse result = apiInstance.getEInvoiceRejectionReason(companyId, documentId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling IssuedEInvoicesApi#getEInvoiceRejectionReason");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
let defaultClient = fattureInCloudSdk.ApiClient.instance;
let OAuth2AuthenticationCodeFlow =
defaultClient.authentications["OAuth2AuthenticationCodeFlow"];
OAuth2AuthenticationCodeFlow.accessToken = "YOUR ACCESS TOKEN";
let apiInstance = new fattureInCloudSdk.IssuedEInvoicesApi();
let companyId = 12345; // Number | The ID of the company.
let documentId = 56; // Number | The ID of the document.
apiInstance.getEInvoiceRejectionReason(companyId, documentId).then(
(result) => {
console.log(
"API called successfully. Returned result: " + JSON.stringify(result)
);
},
(error) => {
console.error(error);
}
);
$config = FattureInCloud\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new FattureInCloud\Api\IssuedEInvoicesApi(
new GuzzleHttp\Client(),
$config
);
$company_id = 12345; // int | The ID of the company.
$document_id = 56; // int | The ID of the document.
try {
$result = $apiInstance->getEInvoiceRejectionReason($company_id, $document_id);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling IssuedEInvoicesApi->getEInvoiceRejectionReason: ', $e->getMessage(), PHP_EOL;
}
configuration = fattureincloud_python_sdk.Configuration()
configuration.access_token = os.environ["ACCESS_TOKEN"]
# Enter a context with an instance of the API client
with fattureincloud_python_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = fattureincloud_python_sdk.IssuedEInvoicesApi(api_client)
company_id = 12345 # int | The ID of the company.
document_id = 56 # int | The ID of the document.
try:
# Get E-Invoice Rejection Reason
api_response = api_instance.get_e_invoice_rejection_reason(company_id, document_id)
print("The response of IssuedEInvoicesApi->get_e_invoice_rejection_reason:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling IssuedEInvoicesApi->get_e_invoice_rejection_reason: %s\n" % e)
FattureInCloud_Ruby_Sdk.configure do |config|
config.access_token = 'YOUR ACCESS TOKEN'
end
api_instance = FattureInCloud_Ruby_Sdk::IssuedEInvoicesApi.new
company_id = 12345 # Integer | The ID of the company.
document_id = 56 # Integer | The ID of the document.
begin
# Get E-Invoice Rejection Reason
result = api_instance.get_e_invoice_rejection_reason(company_id, document_id)
p result
rescue FattureInCloud_Ruby_Sdk::ApiError => e
puts "Error when calling IssuedEInvoicesApi->get_e_invoice_rejection_reason: #{e}"
end
const apiConfig = new Configuration({
accessToken: "YOUR ACCESS TOKEN",
});
let apiInstance = new IssuedEInvoicesApi(apiConfig);
let companyId = 12345; // Number | The ID of the company.
let documentId = 56; // Number | The ID of the document.
apiInstance.getEInvoiceRejectionReason(companyId, documentId).then(
(data) => {
console.log("API called successfully. Returned data: " + data);
},
(error) => {
console.error(error);
}
);