Skip to main content

GetPartnerAccessTokens

The GetPartnerAccessTokens gives access to all the partnersTokens that give you access to invoicing in the behalf of them. A partner can be allocated with more than one token. This allows a partner to be identified in more than one identifier, if needed.

Important

This is the only method that requires the password of the main API user of IPPN service. Passwords must be securely stored, ideally on a separate system from the system used for the rest of the operations.

POST https://bo.magnifinance.com/MagniAPI/Invoicing.asmx

Sample Body

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:inv="http://MagniAPI/Invoicing/">
<soap:Header/>
<soap:Body>
<inv:GetPartnerAccessTokens>
<inv:SpecialAuthentication>
<inv:Email>{{userPartnership}}</inv:Email>
<inv:Token>{{tokenPartnership}}</inv:Token>
<inv:Password>{{basePassword}}</inv:Password>
</inv:SpecialAuthentication>
<inv:PartnerTaxId>992281008</inv:PartnerTaxId>
</inv:GetPartnerAccessTokens>
</soap:Body>
</soap:Envelope>

Request

ParameterRequiredValue
Content-Typerequiredtext/xml

Body

SpecialAuthentication

ParameterRequiredDescription
Emailrequiredstring Platform automation user email.
Tokenrequiredstring(50) The token of the subscription in which the document will be generated.
Passwordrequiredstring(200) Access password.

Request Parameters

ParameterRequiredDescription
CompanyTaxIdrequiredstring(20) Tax id of the partner organization whose tokens will be retrieved. Example value: "599138645"

Response

ParameterDescription
Typestring Description to inform if the request was a success or error. Example value: "Success"
ObjectList of APIAccessTokenBase
AccessToken - string Security token that provides access to the requested partner organization's subscription.
Description - string Description that can be used to differentiate between tokens.
ErrorValueMagniEnum
Value - int Identifies the error with a number. To identify the types of errors in more detail, click here. Example value: "38"
Name - string Identifies the error with a token. Example value: "PartnershipNotFound"
ErrorHumanReadablestring Text that explains the error found. Example value: "ValidationError"
ValidationErrorsList of ValidationError
Type - string Identifies the error with a token. Example value: "DocumentIsADuplicate"
Field - string Name of the field in which validation failed. Example value: "DocumentDetailExternalId"
ElementNumber - int Identifies index of the field in which validation failed. Example value: "67204"
Detail - string Detailed error explanation. Example value: "Duplicate Document"

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/Invoicing.asmx' \
--header 'Content-Type: text/xml' \
--data-raw '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:inv="http://MagniAPI/Invoicing/">
<soap:Header/>
<soap:Body>
<inv:GetPartnerAccessTokens>
<inv:SpecialAuthentication>
<inv:Email></inv:Email>
<inv:Token></inv:Token>
<inv:Password></inv:Password>
</inv:SpecialAuthentication>
<inv:PartnerTaxId></inv:PartnerTaxId>
</inv:GetPartnerAccessTokens>
</soap:Body>
</soap:Envelope>'

JavaScript (fetch)

var myHeaders = new Headers();
myHeaders.append("Content-Type", "text/xml");

var raw = `<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:inv="http://MagniAPI/Invoicing/">
<soap:Header/>
<soap:Body>
<inv:GetPartnerAccessTokens>
<inv:SpecialAuthentication>
<inv:Email>{{userPartnership}}</inv:Email>
<inv:Token>{{tokenPartnership}}</inv:Token>
<inv:Password>{{basePassword}}</inv:Password>
</inv:SpecialAuthentication>
<inv:PartnerTaxId>992281008</inv:PartnerTaxId>
</inv:GetPartnerAccessTokens>
</soap:Body>
</soap:Envelope>`;

var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};

fetch("https://bo.magnifinance.com/MagniAPI/Invoicing.asmx", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));

NodeJs (axios)

var axios = require('axios');

var data = `<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:inv="http://MagniAPI/Invoicing/">
<soap:Header/>
<soap:Body>
<inv:GetPartnerAccessTokens>
<inv:SpecialAuthentication>
<inv:Email>{{userPartnership}}</inv:Email>
<inv:Token>{{tokenPartnership}}</inv:Token>
<inv:Password>{{basePassword}}</inv:Password>
</inv:SpecialAuthentication>
<inv:PartnerTaxId>992281008</inv:PartnerTaxId>
</inv:GetPartnerAccessTokens>
</soap:Body>
</soap:Envelope>`;

var config = {
method: 'post',
url: 'https://bo.magnifinance.com/MagniAPI/Invoicing.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);
});

Important Information

With the token in hand, you can use it, call the DocumentCreate method, replacing the token in the authentication/header with the partnerToken (so you can create a document on behalf of the partner).