Get invoice formats#

This endpoint is used to get invoice formats stored in archive.

Endpoint steps#

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

  2. Get all invoice formats calling the endpoint OutboundFinancialDocument/documentFormats/{documentId};

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 endpoint called */
}

Endpoint Server Base URL#

# SANDBOX - Test Environment
server_base_adress = "dcn-solution.saphety.com/Dcn.Sandbox.WebApi"

# Saphety Invoice Network - Production Environment
#server_base_adress = "dcn-solution.saphety.com/Dcn.Business.WebApi"

1. Get a token (Account/getToken)#

Get a token from your account credentials using endpoint api/Account/getToken
Check here how to obtain an authentication token.

2. Get invoice formats (OutboundFinancialDocument/documentFormats/{documentId})#

* Note: The number of formats returned and their type depends on several factors. In the case of this documentation, the formats are fixed, as you can see in the following example.

2.1 Request structure#

In the endpoint url you need to supply the documentId received

documentId#

  • Description: You need to supply the id of the invoice.

  • Required: Yes

  • Type: string

  • Example: “3fa85f64-5717-4562-b3fc-2c963f66afa6”

2.2 Request example#

outboundFinancialDocumentId = "fc5e547d-8537-4e05-97d5-1159c62efd6f"

# SIN endpoint url for retrieving inforfation on invoice previously sent
service_url = "https://" + server_base_adress + "/api/OutboundFinancialDocument/documentFormats/" + outboundFinancialDocumentId
print (service_url)
https://dcn-solution.saphety.com/Dcn.Sandbox.WebApi/api/OutboundFinancialDocument/documentFormats/fc5e547d-8537-4e05-97d5-1159c62efd6f

2.3 Call the endpoint to get the formats#

Get the invoice formats stored in archive by the Document id (“OutboundFinancialDocumentId“) using endpoint /api/OutboundFinancialDocument/documentFormats/:documentId

headers = {
    'Authorization': 'bearer ' + token
}
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))
[
    {
        "OutboundFinancialDocumentId": "fc5e547d-8537-4e05-97d5-1159c62efd6f",
        "FormatType": "pdf",
        "ContentType": "application/pdf",
        "SignatureProvider": "application/pdf",
        "DocumentLink": "https://invoicenetwork.saphety.com/Dcn.Sandbox.WebApi/api/Content/stream?token=DkIleLbjFKXGOqJwJQ8Alolood97ImN0SWQiOiJlNzRiN2VkNS0zMzU4LTRiNGYtYjQzZi1lMTY0YmRjMDAwMDEiLCJpRHQiOiIyMDIyLTExLTMwIiwiZUR0IjoiMjAyMi0xMi0wMyIsImlCeSI6IlNJTiBBUEkgRE9DVU1FTlRBVElPTiIsImlUbyI6IlNJTiBBUEkgRE9DVU1FTlRBVElPTiIsInMiOiJ3ZWIiLCJhYWgiOmZhbHNlfQ%3D%3D"
    },
    {
        "OutboundFinancialDocumentId": "fc5e547d-8537-4e05-97d5-1159c62efd6f",
        "FormatType": "ubl21",
        "ContentType": "XadesBes",
        "SignatureProvider": "application/xml",
        "DocumentLink": "https://invoicenetwork.saphety.com/Dcn.Sandbox.WebApi/api/Content/stream?token=%2BdA%2FJ17tGd8sW6fJH0brwTqv21V7ImN0SWQiOiJlNzRiN2VkNS0zMzU4LTRiNGYtYjQzZi1lMTY0YmRjMDAwMDMiLCJpRHQiOiIyMDIyLTExLTMwIiwiZUR0IjoiMjAyMi0xMi0wMyIsImlCeSI6IlNJTiBBUEkgRE9DVU1FTlRBVElPTiIsImlUbyI6IlNJTiBBUEkgRE9DVU1FTlRBVElPTiIsInMiOiJ3ZWIiLCJhYWgiOmZhbHNlfQ%3D%3D"
    }
]

The invoice formats are returned at response “Data.DocumentLink”, see the possible values returned

# for loop to see all Data
formats = json_response["Data"];
for format in formats:
    if format["FormatType"] == "pdf":
        print ("PDF: " + format["DocumentLink"] + "\n");
    if format["FormatType"] == "final":
        print ("Final: " + format["DocumentLink"] + "\n");
    if format["FormatType"] == "ubl21":
        print ("UBL: " + format["DocumentLink"] + "\n");
    if format["FormatType"] == "signed":
        print ("Signed: " + format["DocumentLink"] + "\n");
PDF: https://invoicenetwork.saphety.com/Dcn.Sandbox.WebApi/api/Content/stream?token=DkIleLbjFKXGOqJwJQ8Alolood97ImN0SWQiOiJlNzRiN2VkNS0zMzU4LTRiNGYtYjQzZi1lMTY0YmRjMDAwMDEiLCJpRHQiOiIyMDIyLTExLTMwIiwiZUR0IjoiMjAyMi0xMi0wMyIsImlCeSI6IlNJTiBBUEkgRE9DVU1FTlRBVElPTiIsImlUbyI6IlNJTiBBUEkgRE9DVU1FTlRBVElPTiIsInMiOiJ3ZWIiLCJhYWgiOmZhbHNlfQ%3D%3D

UBL: https://invoicenetwork.saphety.com/Dcn.Sandbox.WebApi/api/Content/stream?token=%2BdA%2FJ17tGd8sW6fJH0brwTqv21V7ImN0SWQiOiJlNzRiN2VkNS0zMzU4LTRiNGYtYjQzZi1lMTY0YmRjMDAwMDMiLCJpRHQiOiIyMDIyLTExLTMwIiwiZUR0IjoiMjAyMi0xMi0wMyIsImlCeSI6IlNJTiBBUEkgRE9DVU1FTlRBVElPTiIsImlUbyI6IlNJTiBBUEkgRE9DVU1FTlRBVElPTiIsInMiOiJ3ZWIiLCJhYWgiOmZhbHNlfQ%3D%3D