The Assignar Public API can attach a document, such as a safety plan or a drawing, to a project or an order. It takes three requests: get an upload address, upload the file, then attach it. This article shows the steps for a project, for example in Postman. You need your company's API credentials and some technical knowledge of APIs.
Before you start
API access must be switched on for your company, and you need the Client ID and Client Secret from Settings > API Access on the Assignar dashboard. See How do I create API credentials on the dashboard?.
The full request and response details are in the Assignar API documentation at apidocs.assignar.com.
Step 1: Get an upload address from the Assignar Public API
Make a POST request to /upload-urls/project-document with the file's name in the body:
{
"filename": "kent-st-safety-plan.pdf"
}The response contains:
url: a temporary address where you upload the file in step 2path: the file's location, which you use to attach it in step 3.
{
"url": "https://…amazonaws.com/…/kent-st-safety-plan.pdf?…",
"path": "/fileupload/documents/user_49/1652192049496/kent-st-safety-plan.pdf"
}
Step 2: Upload the file to the Assignar upload address
Make a PUT request to the url from step 1. Send the file as the body, as binary (in Postman, choose binary and select the file).
A successful upload returns HTTP status 200 with an empty body.
Step 3: Attach the uploaded file to a project with the Assignar Public API
Make a POST request to /projects/:projectId/documents, with the path from step 1 in the attachment field. The other fields depend on how your company uses documents:
{
"document_id": 14,
"label": "Kent St safety plan",
"comments": "Issued for construction",
"external_id": "ext-doc-1",
"active": true,
"disabled": false,
"attachment": "/fileupload/documents/user_49/1652192049496/kent-st-safety-plan.pdf",
"expiry_date": "2027-07-20",
"expiry_date_alert": "2027-07-06",
"expiry_number": 0,
"expiry_number_alert": 0
}The document now appears on the project's documents on the Assignar dashboard. To attach a document to an order instead, use the order document endpoints in the API documentation.
Why didn't my document attach with the Assignar Public API?
The upload in step 2 failed. Upload the file to the exact
urlfrom step 1 with aPUTrequest, and send the file as binary, not as form data. The upload address is temporary, so if you wait too long, start again from step 1.The attach in step 3 failed. Check that
attachmentis thepathfrom step 1 (not theurl), and that the project ID exists in your Assignar account."403 Forbidden". Your credentials aren't allowed to make this request. See What can I do with the Assignar Public API?.
