Uploading files

Two types of file uploads exist in Robaws



1) Updating an image/PDF of a line item, article, invoice document, certificate: via temp document bucket
2) Upload documents to projects, invoices, ... any Robaws module having a "documents" tab in the UI

Via temp document bucket



1) Create a temporary document bucket

Request:
POST /api/v2/temp-document-buckets


Response:
{
  "id": "1a4aeabc-0aa8-484d-947a-8ca47e13ee34",
  "expires": "2024-03-09T07:58:22.693Z"
}


2) Upload one or more files to the temporary bucket

By doing a POST to

/api/v2/temp-document-buckets/{your-bucket-uuid}/documents (for files up to 6MB)
/api/v2/temp-document-buckets/{your-bucket-uuid}/document-upload-sessions (for files > 6 MB)

When you created a document upload session, upload each document part using the following URL. Individual parts should be not bigger than 6MB.
(partNumber starts with 0)

POST /api/v2/document-upload-sessions/{sessionId}
Content-Type: application/json

{
  "bytesBase64": "base64encodedData",
  "partNumber": 0
}


Each of these upload endpoints support both application/json content-type and multipart/form-data content-type. Please see the api reference documentation for request details.

3) When the last part is uploaded, or you uploaded a document < 6MB in a single POST, a response is returned containing the document ID. You can then use that document ID to attach it somewhere, for example to a purchase invoice:

PATCH /api/v2/purchase-invoices/123
Content-Type: application/merge-patch+json
{
  "documentId": "your-newly-uploaded-document-id"
}


Note that when a document is attached somewhere, it is removed from the temporary bucket.
Also, when you upload files to a temporary bucket, but you don't attach them somewhere, the files are removed when the bucket expires.


Add documents to entities



Steps are the same as via temp document bucket, but instead of creating a bucket, you can directly start your upload or upload session under the entity resource (for example a project) by doing a POST to:

/api/v2/projects/{your-project-id}/documents (for files up to 6MB)
/api/v2/projects/{your-project-id}/document-upload-sessions (for files > 6 MB)

When you created a document upload session, upload each document part using the following URL. Individual parts should be not bigger than 6MB.
(partNumber starts with 0)

POST /api/v2/document-upload-sessions/{sessionId}
Content-Type: application/json

{
  "bytesBase64": "base64encodedData",
  "partNumber": 0
}


Each of these upload endpoints support both application/json content-type and multipart/form-data content-type. Please see the api reference documentation for request details.
When your upload is finished and a document id is returned, your document is attached to that project. No extra steps are needed.

Bijgewerkt op: 08/02/2024

Was dit artikel nuttig?

Deel uw feedback

Annuleer

Dankuwel!