The Trenchline Jobs API allows you to take complete control of your jobs. You can control all entities within the object, generate file links, create jobs and more. We've tried to cater to every possible use case.
Each API request counts against your total monthly quota. We do this because we want to give you the flexibility to use our API how you wish, and we want to ensure it's sustainable without us having to increase server requirements for third parties.
If there's anything you think we should add, please let us know at [email protected].
To connect to our API, you must use the Authorization header. This can be obtained by emailing us at [email protected]. Your API key has complete access to your account, so please protect it.
curl https://trenchline-intranet.kpitservices.co.uk/api/v1/account/ \ -H "Authorization: Bearer API_TOKEN_HERE"
{ "id": 1923, "name": "Traffic Lights Ltd", "email": "[email protected]", "created": "2022-02-01 13:05:00" }
To list all jobs, you simply need to send a GET request to https://trenchline-intranet.kpitservices.co.uk/api/v1/jobs/list/ and the server will return an array with all jobs created under your client ID.
curl https://trenchline-intranet.kpitservices.co.uk/api/v1/jobs/list/ \ -H "Authorization: Bearer API_TOKEN_HERE"
{ "count": 1, "data": { "jobs": [{ "reference": "000000TL", "client_reference": "AAA-0000", "address": "Test Road, Test Town", "status": "Complete", "description": "This is an example job", "traffic_management_required": 1, "date_created": "2020-12-01 13:00:00", "date_start": "2020-12-08", "date_end": "2020-12-16", "latitude": "50.8000000000000", "longitude": "0.3000000000000", "archived": 0 }] } }
To retrieve a single job from your account you'll need either the internal Trenchline reference or the client reference she used when creating a job. Make a GET request and include the reference and the server will return an array with all jobs created under your client ID.
reference => Internal Trenchline reference or your client reference
curl https://trenchline-intranet.kpitservices.co.uk/api/v1/jobs/single?reference=00000TL \ -H "Authorization: Bearer API_TOKEN_HERE"
{ "job": [ "reference": "00000TL", "client_reference": "AAA-0000", "address": "Test Road, Test Town", "status": "Complete", "description": "This is an example job", "traffic_management_required": 1, "date_created": "2020-12-01 13:00:00", "date_start": "2020-12-08", "date_end": "2020-12-16", "latitude": "50.8000000000000", "longitude": "0.3000000000000", "archived": 0 } }
When a file is uploaded either by an admin or an engineer, it is a linked to the internal Trenchline job reference. To list these jobs, you'll first need to call the 'List a single job' endpoint to retrieve the Trenchline job reference, if you don't have it already. Then you can simply call the endpoint and all files will be listed in an array.
reference => Internal Trenchline reference
curl https://trenchline-intranet.kpitservices.co.uk/api/v1/jobs/files?reference=00000TL \ -H "Authorization: Bearer API_TOKEN_HERE"
{ "count": 2, "data": { "files": [{ "reference": "0000000000", "name": "Test File 1.pdf", "special": "Required:FILE_AMENDED", "catagory": "Default File", "created": "2022-01-06 12:30:00" }, { "reference": "0000000000", "name": "Test File 2.pdf", "special": null, "catagory": "STAT Plan", "created": "2022-01-06 13:00:00" } } }