CommunicationList (SOAP)
This method allows you to get a list of all documents that was communicated by the Tax Communication service to the Tax Authority. Here you can get a list with information about all documents that the service tried to communicate and the current status. You can choose the total of elements that you will receive and divide the response into pages and change the pages choosing the number of elements that will be inside a page.
POST https://bo.magnifinance.com/MagniAPI/taxcommunication.asmx
This operation is also available in the REST API: List Documents (REST).
Sample Body
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tax="http://MagniAPI/TaxCommunication/">
<soapenv:Header/>
<soapenv:Body>
<tax:CommunicationList>
<!--Optional:-->
<tax:authentication>
<!--Optional:-->
<tax:Email>{User}</tax:Email>
<!--Optional:-->
<tax:Token>{Token}</tax:Token>
</tax:authentication>
<!--Optional:-->
<tax:parameters>
<tax:TotalElements>100</tax:TotalElements>
<tax:ElementsPerPage>10</tax:ElementsPerPage>
<tax:CurrentPage>1</tax:CurrentPage>
</tax:parameters>
</tax:CommunicationList>
</soapenv:Body>
</soapenv:Envelope>
Request
Header
| Parameter | Required | Value |
|---|---|---|
| Content-Type | required | text/xml |
Body
Authentication
| Parameter | Required | Description |
|---|---|---|
| required | string(50) The API user email with specific permission to configure this service into the company. | |
| Token | required | string(50) The token of the company that you are trying to active the Tax communication service. |
Parameters
| Parameter | Required | Description |
|---|---|---|
| TotalElements | optional | number The maximum number of documents that will be in the returned list. Example value: "723" |
| ElementsPerPage | optional | number In the request you can send how much elements per page you want to list. The maximum value is "100". Example value: "10" |
| CurrentPage | optional | number The currentpage parameter is used to navigate between the total of pages in the list. Example value: "1" |
The request only supports pagination parameters. There are no date, status, or document type filters available for this operation.
Response
| Parameter | Description |
|---|---|
| RequestId | Unique Id for the request to have a way to identify the request |
| Type | string Description to inform if the request was a success or error. Example value: "Success" |
| Object |
Pagination Parameters
| Parameter | Description |
|---|---|
| Initial | boolean Indicates if this is the initial page of results. Example value: "true" |
| SortAscending | boolean The order that the list of documents will be in the response. This is "true" by default and represent that the list is order by old to new documents. Example value: "true" |
| SearchString | string The search string used to filter the list. |
| TotalElements | number The total number of documents in the list and the total of documents that the service tried to submit to Tax Authority. Example value: "723" |
| ElementsPerPage | number In the request you can send how much elements per page you want to list. This will be returned in this parameter. Example value: "10" |
| CurrentPage | number The currentpage parameter is used to navigate between the total of pages in the list. Example value: "1" |
TaxCommunication > TaxCommunicationBase
| Parameter | Description |
|---|---|
| FiscalDocumentId | int The internal Id of the document. Example value: "67204" |
| FiscalDocumentNumber | string The document's sequence number in the series. Example value: "FT FT/47" |
| Date | date The date of the document. Format: YYYY-MM-DDT00:00:00. Example value: "2022-03-20T00:00:00" |
| DocumentSubTypeId | string(1) The document type code, for example "T" for Invoice/Receipt, "I" for Invoice, "C" for Credit Note or "R" for Receipt. See the document types. Example value: "I" |
| DocumentType | string The name of the document type, for example Invoice/Receipt, Invoice, Credit Note or Receipt. It names the same type as DocumentSubTypeId; see the document types. Example value: "Invoice" |
| FiscalDocumentStatusId | string(1) An FiscalDocumentStatusId return the status of the document but represented by a single letter. Possible types are "C" for Closed and "A" for Cancelled. Example value: "C" |
| FiscalDocumentStatus | string An FiscalDocumentStatus is the status of the document. Possible types are Closed and Cancelled. Example value: "Closed" |
| IsPending | boolean true while the document hasn't been communicated yet and is still being retried automatically. It becomes false once the document is communicated, or after 3 failed attempts. See Documents that weren't communicated. Example value: "false" |
| IsSubmitted | boolean Whether the document was communicated to the Tax Authority successfully. Example value: "true" |
| LastError | string The last error message returned by the Tax Authority when trying to communicate the document. It's only filled in for documents created by the API user making the request. |
| CreatedOn | date It is the date that the document was created in the platform. Example value: "2020-08-12T14:10:20.94" |
Documents that weren't communicated
MagniFinance communicates documents in the background and retries failed ones automatically, up to 3 attempts. Read IsPending and IsSubmitted together:
| IsSubmitted | IsPending | Meaning | What to do |
|---|---|---|---|
true | false | Communicated. | Nothing. |
false | true | Not communicated yet; still being retried automatically. | Wait. |
false | false | Failed 3 times; no more automatic attempts. | Fix the cause shown in LastError (often the AT credentials), then resubmit the document manually. |
To resubmit manually, open Config → Comunicação → Automatic communication of Invoices to AT - Registration in MagniFinance. Failed documents show a red cross in the submission column, with the last error in its tooltip; click it to resubmit that document. This works one closed document at a time and needs the permission to manage automatic AT communication. There's no API operation for it.
Error Response
| Parameter | Description |
|---|---|
| ErrorValue | MagniEnum |
| Value | int Identifies the error with a number. To identify the types of errors in more detail, click here. Example value: "1" |
| Name | string Identifies the error with a token. Example value: "AuthenticationError" |
Request Sample
Below you can see a few examples of the SOAP request in some technologies.
cURL
curl --location --request POST 'https://bo.magnifinance.com/MagniAPI/taxcommunication.asmx' \
--header 'Content-Type: text/xml' \
--data-raw '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tax="http://MagniAPI/TaxCommunication/">
<soapenv:Header/>
<soapenv:Body>
<tax:CommunicationList>
<!--Optional:-->
<tax:authentication>
<!--Optional:-->
<tax:Email></tax:Email>
<!--Optional:-->
<tax:Token></tax:Token>
</tax:authentication>
<!--Optional:-->
<tax:parameters>
<tax:TotalElements>100</tax:TotalElements>
<tax:ElementsPerPage>10</tax:ElementsPerPage>
<tax:CurrentPage>1</tax:CurrentPage>
</tax:parameters>
</tax:CommunicationList>
</soapenv:Body>
</soapenv:Envelope>'
JavaScript (fetch)
var myHeaders = new Headers();
myHeaders.append("Content-Type", "text/xml");
var raw = `<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tax="http://MagniAPI/TaxCommunication/">
<soapenv:Header/>
<soapenv:Body>
<tax:CommunicationList>
<!--Optional:-->
<tax:authentication>
<!--Optional:-->
<tax:Email></tax:Email>
<!--Optional:-->
<tax:Token></tax:Token>
</tax:authentication>
<!--Optional:-->
<tax:parameters>
<tax:TotalElements>100</tax:TotalElements>
<tax:ElementsPerPage>10</tax:ElementsPerPage>
<tax:CurrentPage>1</tax:CurrentPage>
</tax:parameters>
</tax:CommunicationList>
</soapenv:Body>
</soapenv:Envelope>`;
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://bo.magnifinance.com/MagniAPI/taxcommunication.asmx", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Node.js (axios)
var axios = require('axios');
var data = `<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tax="http://MagniAPI/TaxCommunication/">
<soapenv:Header/>
<soapenv:Body>
<tax:CommunicationList>
<!--Optional:-->
<tax:authentication>
<!--Optional:-->
<tax:Email></tax:Email>
<!--Optional:-->
<tax:Token></tax:Token>
</tax:authentication>
<!--Optional:-->
<tax:parameters>
<tax:TotalElements>100</tax:TotalElements>
<tax:ElementsPerPage>10</tax:ElementsPerPage>
<tax:CurrentPage>1</tax:CurrentPage>
</tax:parameters>
</tax:CommunicationList>
</soapenv:Body>
</soapenv:Envelope>`;
var config = {
method: 'post',
url: 'https://bo.magnifinance.com/MagniAPI/taxcommunication.asmx',
headers: {
'Content-Type': 'text/xml'
},
data: data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Python (requests)
import requests
url = "https://bo.magnifinance.com/MagniAPI/taxcommunication.asmx"
headers = {
"Content-Type": "text/xml"
}
body = """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tax="http://MagniAPI/TaxCommunication/">
<soapenv:Header/>
<soapenv:Body>
<tax:CommunicationList>
<tax:authentication>
<tax:Email></tax:Email>
<tax:Token></tax:Token>
</tax:authentication>
<tax:parameters>
<tax:TotalElements>100</tax:TotalElements>
<tax:ElementsPerPage>10</tax:ElementsPerPage>
<tax:CurrentPage>1</tax:CurrentPage>
</tax:parameters>
</tax:CommunicationList>
</soapenv:Body>
</soapenv:Envelope>"""
response = requests.post(url, headers=headers, data=body)
print(response.text)
PHP (cURL)
<?php
$url = "https://bo.magnifinance.com/MagniAPI/taxcommunication.asmx";
$headers = [
"Content-Type: text/xml"
];
$body = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tax="http://MagniAPI/TaxCommunication/">
<soapenv:Header/>
<soapenv:Body>
<tax:CommunicationList>
<tax:authentication>
<tax:Email></tax:Email>
<tax:Token></tax:Token>
</tax:authentication>
<tax:parameters>
<tax:TotalElements>100</tax:TotalElements>
<tax:ElementsPerPage>10</tax:ElementsPerPage>
<tax:CurrentPage>1</tax:CurrentPage>
</tax:parameters>
</tax:CommunicationList>
</soapenv:Body>
</soapenv:Envelope>';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
C# (HttpClient)
using System.Net.Http;
using System.Text;
var client = new HttpClient();
var body = @"<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:tax=""http://MagniAPI/TaxCommunication/"">
<soapenv:Header/>
<soapenv:Body>
<tax:CommunicationList>
<tax:authentication>
<tax:Email></tax:Email>
<tax:Token></tax:Token>
</tax:authentication>
<tax:parameters>
<tax:TotalElements>100</tax:TotalElements>
<tax:ElementsPerPage>10</tax:ElementsPerPage>
<tax:CurrentPage>1</tax:CurrentPage>
</tax:parameters>
</tax:CommunicationList>
</soapenv:Body>
</soapenv:Envelope>";
var content = new StringContent(body, Encoding.UTF8, "text/xml");
var response = await client.PostAsync(
"https://bo.magnifinance.com/MagniAPI/taxcommunication.asmx",
content
);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
Java (HttpClient)
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
HttpClient client = HttpClient.newHttpClient();
String body = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tax=\"http://MagniAPI/TaxCommunication/\">"
+ " <soapenv:Header/>"
+ " <soapenv:Body>"
+ " <tax:CommunicationList>"
+ " <tax:authentication>"
+ " <tax:Email></tax:Email>"
+ " <tax:Token></tax:Token>"
+ " </tax:authentication>"
+ " <tax:parameters>"
+ " <tax:TotalElements>100</tax:TotalElements>"
+ " <tax:ElementsPerPage>10</tax:ElementsPerPage>"
+ " <tax:CurrentPage>1</tax:CurrentPage>"
+ " </tax:parameters>"
+ " </tax:CommunicationList>"
+ " </soapenv:Body>"
+ "</soapenv:Envelope>";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://bo.magnifinance.com/MagniAPI/taxcommunication.asmx"))
.header("Content-Type", "text/xml")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Example Response
Success
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<CommunicationListResponse xmlns="http://MagniAPI/TaxCommunication/">
<ResponseCommunicationList>
<RequestId>2ec7e0ba-ce40-4a4c-a053-df081be53533</RequestId>
<Type>Success</Type>
<Object>
<Parameters>
<Initial>true</Initial>
<SortAscending>true</SortAscending>
<SearchString />
<TotalElements>834</TotalElements>
<ElementsPerPage>10</ElementsPerPage>
<CurrentPage>1</CurrentPage>
</Parameters>
<TaxCommunication>
<TaxCommunicationBase>
<FiscalDocumentId>31824</FiscalDocumentId>
<FiscalDocumentNumber>FTM FTmu/23</FiscalDocumentNumber>
<Date>2020-10-16T00:00:00</Date>
<DocumentSubTypeId>I</DocumentSubTypeId>
<DocumentType>Invoice</DocumentType>
<FiscalDocumentStatusId>C</FiscalDocumentStatusId>
<FiscalDocumentStatus>Closed</FiscalDocumentStatus>
<IsPending>true</IsPending>
<IsSubmitted>false</IsSubmitted>
<LastError />
<CreatedOn>2020-08-12T14:10:20.94</CreatedOn>
</TaxCommunicationBase>
<TaxCommunicationBase>
<FiscalDocumentId>35455</FiscalDocumentId>
<FiscalDocumentNumber>NC TestNC/5</FiscalDocumentNumber>
<Date>2020-08-20T00:00:00</Date>
<DocumentSubTypeId>C</DocumentSubTypeId>
<DocumentType>Credit Note</DocumentType>
<FiscalDocumentStatusId>C</FiscalDocumentStatusId>
<FiscalDocumentStatus>Closed</FiscalDocumentStatus>
<IsPending>true</IsPending>
<IsSubmitted>false</IsSubmitted>
<LastError />
<CreatedOn>2020-08-24T17:57:09.25</CreatedOn>
</TaxCommunicationBase>
<TaxCommunicationBase>
<FiscalDocumentId>35463</FiscalDocumentId>
<FiscalDocumentNumber>FS FS/229</FiscalDocumentNumber>
<Date>2020-08-24T00:00:00</Date>
<DocumentSubTypeId>S</DocumentSubTypeId>
<DocumentType>Simplified Invoice</DocumentType>
<FiscalDocumentStatusId>C</FiscalDocumentStatusId>
<FiscalDocumentStatus>Closed</FiscalDocumentStatus>
<IsPending>true</IsPending>
<IsSubmitted>false</IsSubmitted>
<LastError />
<CreatedOn>2020-08-24T20:07:08.213</CreatedOn>
</TaxCommunicationBase>
</TaxCommunication>
</Object>
</ResponseCommunicationList>
</CommunicationListResponse>
</soap:Body>
</soap:Envelope>
Error
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<CommunicationListResponse xmlns="http://MagniAPI/TaxCommunication/">
<ResponseCommunicationList>
<RequestId>5165e271-97ec-4425-aa33-f7c32c7c6f3d</RequestId>
<Type>Error</Type>
<ErrorValue>
<Value>1</Value>
<Name>AuthenticationError</Name>
</ErrorValue>
</ResponseCommunicationList>
</CommunicationListResponse>
</soap:Body>
</soap:Envelope>