Public API - Uploading and Attaching Documents

  • Updated

The public API supports attaching a document to projects and orders. The example below outlines the steps for adding a document to a project using Postman. There is also a downloadable PDF attached at the bottom of this page. 

☁️ Generate an S3 URL and File Path

You first need to generate an S3 URL which will provide a url for adding the document to S3 and a path which will be used to attach the document to a project.

Request

Make a POST request to /upload-urls/project-document with the following body:

{ "filename": "your-file-name.txt" }

Response

The response contains a url which will be used to put a document into an S3 bucket and a path which is used when referencing a document on a project or order document request.

{ "url": "https://assignarassets-usw2.s3.us-west-2.amazonaws.com/production/tmac_excavations/fileupload/documents/user_49/1652192049496/tom-testing-1.txt?Content-Type=text%2Fplain&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIA3CITDVEXCDBG7SHI%2F20220510%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20220510T141409Z&X-Amz-Expires=600&X-Amz-Security-Token=IQoJb3JpZ2luX2VjED4aCXVzLXdlc3QtMiJHMEUCIHyoEddNQeIZH4ADBylcVG8D5uFyGys%2Fbby9YLsDIFXPAiEA3rtqZVvEGFI3d5dn%2B8qkWmob3VHfOC%2FmWzl0ET5MtMMqoQIIFxAAGgw3NjA3ODYxNjgxMTAiDC%2B5t94V5PzuC7rQWir%2BASdTKJN6GK4by%2BqpTCotM7%2Ffilvn3c1fRB%2BYW%2BO5Xsw0WoGoXVjGpjt89UkagJ%2BnsvVNKeALD%2B8OzDjCtbGesdeQeJHjK6W%2BYr3%2By6u3Z1cG4z%2B5hHDLMgN5Aqrl%2BU1bAZodQ%2FuhFwC5CN7b4oQY6aNeyJMTrdUjPeiibo4M3VAjLtLIAl%2FhvLprt%2Fc19KOM%2FOBe%2FcdWcJmMSgF7cYPWUJaebd2%2Bw%2FYFD5yMlA53GfsS34rizoTTJEVgzX4l4Hgw5s600aVdXPCOHSk7fFcx88RTULh5TOoWbb5RC9Xziezs8qz7LimOkPK7CPudBi6Y%2BR5EPjzYE5zHEI%2F8TZVHMMPX6ZMGOpoBoNQZYtW%2FmcJqp4LZkY15CFPc1Pk8dAdEvIJJ4iBj4Vr9FU33PBGApoZ%2Bl1dtlxV1OPRQPkbXjF2F3rq2%2B%2FZa8%2FBqWdjLackgaDilNlvFN9shefUo0jAppMmmoM7bs%2FOBnaRQ1tX0ZlSq2uUFYC5yBuO47VW9%2B00fMj6MDoiiaZ18zcbD1j1dJUbwx%2ByCFWHQcvfxyLiTlnKiiw%3D%3D&X-Amz-Signature=0aa5959d35bb22a728731c9887a330cfbeca357ad3a37bde31629ef56184a2cc&X-Amz-SignedHeaders=host", "path": "/fileupload/documents/user_49/1652192049496/tom-testing-1.txt" }

Example

 

 

⬆️ Upload a Document to S3

Once an S3 url has been generated, it can be used to store a document.

Request

Using the url from the previous step, make a PUT request, selecting binary for the body and selecting the document for upload.

Response

A successful response will have an http status of 200 and there will be nothing in the body.

Example

 

📎 Attach the document to a Project

Now that a document has been added to S3, it can be attached to a project.

Request

Make a POST request to /projects/:projectId/documents using the path from the first step in the attachment field. The remaining properties on the request will depend on the business requirements of the document.

{ "document_id": 14, "label": "Tom Testing Upload", "comments": "This is a comment", "external_id": "ext-doc-1", "active": true, "disabled": false, "attachment": "/fileupload/documents/user_49/1652192049496/tom-testing-1.txt", "expiry_date": "2023-07-20", "expiry_date_alert": "2023-07-20", "expiry_number": 0, "expiry_number_alert": 0 }

Example:

 
 
 

 

Was this article helpful?

0 out of 0 found this helpful