Export documents and additional data from Trackline to Holded using API queries
Learn step-by-step how to integrate Trackline with Holded.
Trackline is a functionality of the Code Contract platform that enables automated data collection without altering workflows or requiring manual input.
Step 1: Obtain the authentication token
Holded must authenticate to the Trackline API via a POST request to obtain a JWT token. This token will be used in subsequent requests.
Request from Holded (HTTP Request):
POST /login HTTP/1.1
Host: api.codecontractplattform.com
Content-Type: application/json
{
"email": "holded_integration_user",
"password": "holded_secure_password"
}
Expected response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"token": "eyJ0eXAiOiJKV1QiLCJ..."
}
Store the token in Holded and include it in each request as a Bearer Token in the Authorization header.
Step 2: Query additional data and files in Trackline from Holded
Query process metadata:
Holded can retrieve information about a specific process using process_id or process_name.
Request:
GET /track-line/ext/track-path/metadata?process_id=12345 HTTP/1.1
Host: api.codecontractplattform.com
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJ...
Expected response (JSON):
{
"process_id": "12345",
"name": "Holded Billing Process",
"status": "In Progress",
"created_at": "2024-02-09T10:30:00Z",
"documents": [
{
"doc_id": "98765",
"doc_name": "Invoice_001.pdf",
"doc_type": "Invoice"
}
]
}
Download an attachment
Once metadata is retrieved, Holded can download an attachment using its attachment_id.
Request:
GET /track-line/ext/attachment/file?attachment_id=98765 HTTP/1.1
Host: api.codecontractplattform.com
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJ...
Expected response (File):
The server will respond with a PDF, XML or other appropriate file format. Holded may store or process the file.
Integration in Holded (Example using JavaScript – Node.js)
const axios = require('axios');
const fs = require('fs');
async function integrateTracklineWithHolded() {
try {
const loginResponse = await axios.post('https://api.codecontractplattform.com/api/login', {
email: "holded_integration_user",
password: "holded_secure_password"
});
const token = loginResponse.data.token;
const headers = { Authorization: `Bearer ${token}` };
const metadataResponse = await axios.get(
'https://api.codecontractplattform.com/api/track-line/ext/track-path/metadata?process_id=12345',
{ headers }
);
console.log("Metadata retrieved:", metadataResponse.data);
const attachmentId = metadataResponse.data.documents[0].doc_id;
const attachmentResponse = await axios.get(
`https://api.codecontractplattform.com/api/track-line/ext/attachment/file?attachment_id=${attachmentId}`,
{ headers, responseType: 'arraybuffer' }
);
fs.writeFileSync("Invoice_001.pdf", attachmentResponse.data);
console.log("File downloaded successfully.");
} catch (error) {
console.error("Integration error:", error.message);
}
}
integrateTracklineWithHolded();
Summary
✔️ Step 1: Holded gets JWT token via authentication
✔️ Step 2: Holded queries process metadata with process_id
✔️ Step 3: Holded downloads attachments using attachment_id
✔️ Step 4: Integration possible via Node.js, Python, or API connectors
For more info or support, contact the Code Contract team. 🚀
