Activation Set
This method allows you to activate or deactivate the Tax Communication service that enables the automatic communication of invoices to the government after creation.
To use this method you need a specific Tax Authority user and password created with the appropriate permissions ('WFA - Comunicacao de dados de faturas' and/or 'WDT - Comunicacao de dados de documentos de transporte') inside the Portal das Financas website.
When you call the method to activate the service, the credentials are validated against the Tax Authority portal and only upon successful validation is the service set to active.
POST https://bo.magnifinance.com/MagniAPI/taxcommunication.asmx
Sample Body
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tax="http://MagniAPI/TaxCommunication/">
<soapenv:Header/>
<soapenv:Body>
<tax:ActivationSet>
<!--Optional:-->
<tax:authentication>
<!--Optional:-->
<tax:Email>{emailAPI}</tax:Email>
<!--Optional:-->
<tax:Token>{token}</tax:Token>
</tax:authentication>
<!--Optional:-->
<tax:activation>
<!--Optional:-->
<tax:Username>{User}</tax:Username>
<!--Optional:-->
<tax:Password>{password}</tax:Password>
<tax:IsActive>true</tax:IsActive>
</tax:activation>
</tax:ActivationSet>
</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 activate the Tax Communication service. |
Activation
| Parameter | Required | Description |
|---|---|---|
| Username | required | string(50) The email address of the Tax Authority (AT) user with the appropriate permission (WFA / WDT). You can create a user in the AT website by navigating through the sections 'Servicos tributarios / Outros servicos / Gestao de utilizadores'. There, create a user and give it the appropriate permissions 'WFA - Comunicacao de dados de faturas' and/or 'WDT - Comunicacao de dados de documentos de transporte'. Example value: "info@magnifinance.com" |
| Password | required | string (min = 6 and max = 50) The password of the Tax Authority user of the company with the appropriate permission (WFA / WDT). For security reasons, the password should have more than 6 characters but less than 50 characters. Example value: "XYs123cath4rlaYcbyJwNeOp" |
| IsActive | required | boolean When you set true, if the Tax Authority service accepts your user and password, the service will be set to Active. If you set false, the request will remove the data about this user and deactivate the tax communication service for this company. Example value: "true" |
The AT credentials are validated in real-time against the Portal das Financas. If the credentials are invalid or the user does not have the required WFA/WDT permissions, the activation will fail and IsActive will return false.
To create the required AT user, go to Portal das Financas and navigate to Servicos tributarios > Outros servicos > Gestao de utilizadores. Create a new user and assign the permissions WFA - Comunicacao de dados de faturas and/or WDT - Comunicacao de dados de documentos de transporte.
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 | |
| IsActive | boolean It will return if the Tax Communication service is active or not. In case the credentials fail validation at the Tax Authority portal, the API will return false. Example value: "true" |
| ErrorMessage | string Unprocessed error message. |
| 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 check some 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:ActivationSet>
<tax:authentication>
<tax:Email>api@magnifinance.com</tax:Email>
<tax:Token>your-company-token</tax:Token>
</tax:authentication>
<tax:activation>
<tax:Username>at-user@example.com</tax:Username>
<tax:Password>XYs123cath4rlaYcbyJwNeOp</tax:Password>
<tax:IsActive>true</tax:IsActive>
</tax:activation>
</tax:ActivationSet>
</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:ActivationSet>
<tax:authentication>
<tax:Email>api@magnifinance.com</tax:Email>
<tax:Token>your-company-token</tax:Token>
</tax:authentication>
<tax:activation>
<tax:Username>at-user@example.com</tax:Username>
<tax:Password>XYs123cath4rlaYcbyJwNeOp</tax:Password>
<tax:IsActive>true</tax:IsActive>
</tax:activation>
</tax:ActivationSet>
</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:ActivationSet>
<tax:authentication>
<tax:Email>api@magnifinance.com</tax:Email>
<tax:Token>your-company-token</tax:Token>
</tax:authentication>
<tax:activation>
<tax:Username>at-user@example.com</tax:Username>
<tax:Password>XYs123cath4rlaYcbyJwNeOp</tax:Password>
<tax:IsActive>true</tax:IsActive>
</tax:activation>
</tax:ActivationSet>
</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:ActivationSet>
<tax:authentication>
<tax:Email>api@magnifinance.com</tax:Email>
<tax:Token>your-company-token</tax:Token>
</tax:authentication>
<tax:activation>
<tax:Username>at-user@example.com</tax:Username>
<tax:Password>XYs123cath4rlaYcbyJwNeOp</tax:Password>
<tax:IsActive>true</tax:IsActive>
</tax:activation>
</tax:ActivationSet>
</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";
$body = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tax="http://MagniAPI/TaxCommunication/">
<soapenv:Header/>
<soapenv:Body>
<tax:ActivationSet>
<tax:authentication>
<tax:Email>api@magnifinance.com</tax:Email>
<tax:Token>your-company-token</tax:Token>
</tax:authentication>
<tax:activation>
<tax:Username>at-user@example.com</tax:Username>
<tax:Password>XYs123cath4rlaYcbyJwNeOp</tax:Password>
<tax:IsActive>true</tax:IsActive>
</tax:activation>
</tax:ActivationSet>
</soapenv:Body>
</soapenv:Envelope>';
$headers = [
"Content-Type: text/xml"
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
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:ActivationSet>
<tax:authentication>
<tax:Email>api@magnifinance.com</tax:Email>
<tax:Token>your-company-token</tax:Token>
</tax:authentication>
<tax:activation>
<tax:Username>at-user@example.com</tax:Username>
<tax:Password>XYs123cath4rlaYcbyJwNeOp</tax:Password>
<tax:IsActive>true</tax:IsActive>
</tax:activation>
</tax:ActivationSet>
</soapenv:Body>
</soapenv:Envelope>";
var request = new HttpRequestMessage(HttpMethod.Post,
"https://bo.magnifinance.com/MagniAPI/taxcommunication.asmx");
request.Content = new StringContent(body, Encoding.UTF8, "text/xml");
var response = await client.SendAsync(request);
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:ActivationSet>
<tax:authentication>
<tax:Email>api@magnifinance.com</tax:Email>
<tax:Token>your-company-token</tax:Token>
</tax:authentication>
<tax:activation>
<tax:Username>at-user@example.com</tax:Username>
<tax:Password>XYs123cath4rlaYcbyJwNeOp</tax:Password>
<tax:IsActive>true</tax:IsActive>
</tax:activation>
</tax:ActivationSet>
</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>
<ActivationSetResponse xmlns="http://MagniAPI/TaxCommunication/">
<ResponseActivationSet xsi:type="ResponseOfActivation">
<RequestId>08d52dd7-cfba-4542-abeb-935504ccdbaa</RequestId>
<Type>Success</Type>
<Object>
<IsActive>true</IsActive>
</Object>
</ResponseActivationSet>
</ActivationSetResponse>
</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>
<ActivationSetResponse xmlns="http://MagniAPI/TaxCommunication/">
<ResponseActivationSet>
<RequestId>5165e271-97ec-4425-aa33-f7c32c7c6f3d</RequestId>
<Type>Error</Type>
<ErrorValue>
<Value>1</Value>
<Name>AuthenticationError</Name>
</ErrorValue>
</ResponseActivationSet>
</ActivationSetResponse>
</soap:Body>
</soap:Envelope>
For a complete list of error codes and their meanings, see the Error Codes page.