Find the insights and best practices about our product.
🤖 Trackline – Proactive automation
🔎 SmartCheck – Digital evidence
🚀 Use cases by sector
Food sector
Construction sector
Industrial sector
Logistics sector
👤 Role based use cases
📊 Use cases by functionality
🤝🏻 Partners
Trackline Integration with SAGE

Trackline Integration with SAGE
Export documents and additional data from Trackline to SAGE via API queries
Step-by-step guide to integrate Trackline with SAGE
Trackline is a functionality of the Code Contract platform that enables automation of information collection without changing workflows or requiring manual input.

If you wish to integrate Trackline with SAGE to retrieve documents and process data, follow these steps using JWT Token authentication.

Step 1: Obtain the Authentication Token
SAGE must authenticate to the Trackline API via a POST request to obtain a JWT token. This token will be used for all subsequent requests.

Request from SAGE (HTTP Request)

http
POST /login HTTP/1.1
Host: api.codecontractplattform.com
Content-Type: application/json

{
"email": "sage_integration_user",
"password": "sage_secure_password"
}

Expected Response

http
HTTP/1.1 200 OK
Content-Type: application/json

{
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmV..."
}

The token value must be stored in SAGE and sent in each request as a Bearer Token in the Authorization header.

Step 2: Query additional data and files from Trackline via SAGE
Query additional process data
SAGE can retrieve data on a specific process using either process_id or process_name.

Request from SAGE

http
GET /track-line/ext/track-path/metadata?process_id=12345 HTTP/1.1
Host: api.codecontractplattform.com
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmV...

Expected Response

{
"process_id": "12345",
"name": "SAGE Billing Process",
"status": "In Progress",
"created_at": "2024-02-09T10:30:00Z",
"documents": [
{
"doc_id": "98765",
"doc_name": "Invoice_001.pdf",
"doc_type": "Invoice"
}
]
}

SAGE can use this data to automate document and process management.

Download an attachment
Once metadata is obtained, SAGE can download an attachment using the attachment_id.

Request from SAGE

http
GET /track-line/ext/attachment/file?attachment_id=98765 HTTP/1.1
Host: api.codecontractplattform.com
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmcmV...

Expected Response (File)
The server will respond with a PDF, XML or another format that SAGE can store or process.

Integration in SAGE (Python sample code for Sage 200 or Sage X3)
If you need to integrate this functionality using Python, you can use the following script:

import requests

# Step 1: Get the JWT Token
login_url = "https://api.codecontractplattform.com/api/login"
credentials = {
"email": "sage_integration_user",
"password": "sage_secure_password"
}

response = requests.post(login_url, json=credentials)
token = response.json().get("token")

# Step 2: Query metadata
headers = {
"Authorization": f"Bearer {token}"
}

metadata_url = "https://api.codecontractplattform.com/api/track-line/ext/track-path/metadata?process_id=12345"
response = requests.get(metadata_url, headers=headers)
metadata = response.json()

print("Metadata retrieved:", metadata)

# Step 3: Download attachment
attachment_id = metadata["documents"][0]["doc_id"]
attachment_url = f"https://api.codecontractplattform.com/api/track-line/ext/attachment/file?attachment_id={attachment_id}"

response = requests.get(attachment_url, headers=headers)

with open("Invoice_001.pdf", "wb") as file:
file.write(response.content)

print("File downloaded successfully.")

Summary
✔️ Step 1: SAGE obtains the JWT Token
✔️ Step 2: SAGE queries process metadata with process_id
✔️ Step 3: SAGE downloads attachments with attachment_id
✔️ Step 4: SAGE can automate the whole flow using Python, Java or API connectors

If you need further support, contact the Code Contract team. 🚀