Get integrated destinations#

Use this service to get all or filtred integrated destinations.

Service steps#

  1. Get a token from your credentials by calling the service Account/getToken;

  2. Get all integrated destinations calling the service CompanyConnections/destinations or filtred integrated destinations by CompanyConnections/destinations/{searchValue};

Response structure from server#

When a request is well formed and the authentication data is correct the system responds with a message envelope as follows:

	"CorrelationId": "<GUID>", /* for correlation purposes */
	"IsValid": true,           /* false in case of erros */
	"Errors": [],              /* if empty is a good signal */
	"Data": "<Service Response Data>"   /* the data retuned ex: token, invoice status, dependent on the service called */

1. Get a token (Account/getToken)#

Credentials have be given to you, according to your registration at SANDBOX or Saphety Invoice Network:

  • For Test purposes, the user and password defined at SANDBOX registration

  • For Production, the user and password defined at Saphety Invoice Network registration

Use those credentials to get a token at:

# SANDBOX - Test Environment
server_base_adress = ""

# Saphety Invoice Network - Production Environment
#server_base_adress = ""
import requests
import json

# SIN account service url
service_url = "https://" + server_base_adress + "/api/Account/getToken"

# the username and password you registerd in SIN
username = ''
password = 'request_password'

# auhtentication data goes in payload as json
payload = {
      'Username': username,
      'Password': password
# payload goes in json, serialize the payloal object to json
# indicate in header that payload is json
headers = {
    'content-type': 'application/json'
# POST request to get a token
response = requests.request("POST", service_url, data=request_data, headers=headers)

* Note: the credentials (user and password) in this documentation were created by Saphety and can only be used in the SANDBOX environment. For tests we recommend that you use the credentials you obtained when registering with the SANDBOX.

# formating the response to json for visualization purposes only
json_response = json.loads(response.text)
print(json.dumps(json_response, indent=4))
    "CorrelationId": "caa3cc1e-e44f-4809-975f-9e0fba1fa910",
    "IsValid": true,
    "Errors": [],
    "Data": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1laWQiOiJzaW5fYXBpX2RvY3VtZW50YXRpb25fdXNlckBzYXBoZXR5LmNvbSIsInVuaXF1ZV9uYW1lIjoiU0lOIEFQSSBET0NVTUVOVEFUSU9OIiwic3lzdGVtX2FkbWluIjoiRmFsc2UiLCJzZXNzaW9uX2lkIjoiZjVmMmMxOWUtMjBlMi00OTNmLWE4NzMtMDE0ZjI1MzJhOWVlIiwiY3AiOiJzaW5fYXBpX2RvY3VtZW50YXRpb25fdXNlckBzYXBoZXR5LmNvbSIsInJsIjoiRGV2ZWxvcGVyIiwibmJmIjoxNjE1ODI1MzgyLCJleHAiOjE2MTU4NTQxODIsImlhdCI6MTYxNTgyNTMyMiwiaXNzIjoiaHR0cHM6Ly93d3cuc2FwaGV0eS5jb20vIiwiYXVkIjoiaHR0cHM6Ly93d3cuc2FwaGV0eS5jb20vRGNuU2FuZGJveCJ9.DbUTwpckCVAEp7H-cyNVjAzC1hrZdevKpm4iWtmxZEo"
# your token is at:
token = json_response["Data"];
print (token)

2. Get integrated destinations (CompanyConnections/destinations OR CompanyConnections/destinations/{searchValue})#

* Note: Here we will use the service CompanyConnections/destinations/{searchValue} to get just one integrated company, searching for the company name. But you can user the service CompanyConnections/destinations to get all integrated companies!

Build the service endpoint url#

In the service url you need to supply the searchValue, in this case we will use a company name

# SIN service url for retrieving inforfation on invoice previously sent
service_url = """{ServerBaseUrl}/api/CompanyConnections/destinations/{searchValue}""".format(
service_url = "https://" + service_url
print (service_url)

Call the service to get the integrated destination#

You will call the service endpoint url

# build the request
headers = {
    'Authorization': 'bearer ' + token
# POST request to send the invoice
response = requests.request("GET", service_url, headers=headers)

# formating the response to json for visualization purposes only
json_response = json.loads(response.text)
print(json.dumps(json_response["Data"], indent=4))
        "IntlVatCode": "PT507957547",
        "CompanyName": "SAPHETY LEVEL - TRUSTED SERVICES, S.A.",
        "AddressLine": "Rua do Viriato, N\u00ba13 - 3\u00baPISO",
        "City": "LISBOA",
        "ZipCode": "1050-233",
        "ZipArea": "LISBOA",
        "CountryCode": "PT",
        "CommercialRecordWebCode": "",
        "TenantCode": null,
        "LanguageCode": "pt",
        "Status": "Active",
        "IsPartner": false,
        "CreationDate": "2010-09-29 15:25"