Document APIs

How can I access Documents using Oneserve APIs?

This guide will walk you through getting Documents from our new suite of APIs:

 

 

Authentication: /v0/auth/login

This end point uses username/password to generate a token which can be used in subsequent calls

Request

POST https://api-cans.oneserve.co.uk/v1/auth/login 

{ "user": { "userName": "[user]", "companyName": "[client]" }, "password": "[password]" }
  

Response 

{ "token":
   { "jwtToken": "[jwtToken]",
   
"payload": { ... },
   },
   "refreshToken": { "token": "[refreshToken]" } }
}

 

The jwtToken in the response should be used in subsequent calls to the APIs as a Bearer Token, eg:

 

GET Jobs: /v0/jobs [OPTIONAL]

There is the v0 endpoint which will get a list of jobs, however this does not include any filtering to limit by site or date.

 getjobsapis
 

GET Job Details: /v1/jobs

For a given Oneserve Job Ref, you can get information about the Job (including the job id) from this endpoint

 getjobdetailsapi
 

GET Document Ids: /v1/jobs/{jobId}/documents

From there, you can the get the job id (in this case 464640) and call the job documents API to get the list of documents: 

 getjobdocumentapi

 

GET PresignedUrl: /v1/documents/{documentId}/presignedUrl

You can then use that document id to call the presignedUrl to get the download URL:

getjobdocumentapi
This link has a 10 second expiry, and a GET API call should be made to the URL returned

 

POST Documents: /v1/jobs/{jobId}/documents

You can use the job id to post documents:

This post should contain details about the document, and will return a link to post the photo to. This link has a 10 second expiry.