Table of Contents


Upload documents

Use this REST endpoint to upload documents or files to the Magentrix library, attachments, or Salesforce Files. Publicly available documents can be uploaded via an HTTP POST request and are stored in the chosen location (Document Library, Notes & Attachments, or Salesforce Files).

If an ID is provided in the request:

  • Document: The existing document’s metadata is updated. If a file download URL is provided, a new version is added.
  • Attachment: The existing attachment is overwritten.
  • Salesforce Files: A new version is added.
     
curl POST 'https://{domain}/api/3.0/file'
 -H 'Content-Type: application/json'
 -H 'Accept: application/json'
 -H 'Authorization: Bearer {access_token}'
 -d '{
      "Id": "{documentId}", 
      "File": "{public_file_url}",
      "FileName": "{file_name_with_extension}",
      "Title": "{document_title}",
      "Description": "{document_description}",
      "ParentId": "{folder_or_parent_id}", 
      "Type": "{file_type}", 
      "ContentType": "{file_content_type}"
    }'

 

Request Body

Submit a JSON or XML object with the following data fields. Magentrix will parse your data payload based on "Content-Type" header value.
 

Id string Optional

If you’re uploading a new version of an existing document or updating its information, provide the original document’s ID. In this scenario, the File field becomes optional.
 

File string Required

A publicly accessible download URL that Magentrix can reach. Once you submit the request, Magentrix will download the file from this URL. This approach allows larger files to be transferred without hitting HTTP request size limits.

FileName string Required

The current file name with an extension. Only valid file name characters are allowed.

Type string Required
The type of file being uploaded. Valid options are "document", "attachment", or "Salesforce file".

ParentId string Optional/Conditional

  • If Type is "document", this must be the folder ID where the document will be stored.
  • If Type is "attachment", this must be the ID of the record to which the file will be attached.
  • If Type is "salesforce file", the same requirement applies.


Title string Optional
A user-friendly name to reference this document.
 

Description string Optional

An optional description of the file is uploaded.

 

Attention: The source domain of the files should be white-listed in Magentrix for security reasons.

Example

The following shows a request to update an existing file:

curl POST 'https://{domain}/api/3.0/file'
 -H 'Content-Type: application/json'
 -H 'Accept: application/json'
 -H 'Authorization: Bearer {access_token}'
 -d '{
     "Id": "7Ot00000000FXzb009Q",
     "File": "https://docs.google.com/document/d/1CGnFEOIolBUpEoE0ZflodJPCtWB7E9qVWqCufKYsk3g/export?format=doc",
     "FileName": "RESTUpload.docx",
     "Title": "LMS courses and lessons", 
     "Description": "From Google drive",
     "ParentId": "7Os00000000003Z009Q",
     "Type": "document",
     "ContentType": "application/ms-word"
 }'


Successful Response

HTTP 200 OK

{
   "fileId": "00T3000023D23",
   "success": true
}

 

Failed Response

HTTP 406 Not Acceptable

{
   "message": "Request body is empty. A valid JSON payload is required to upload a file.",
   "success": false
}

 

HTTP 404 Not Found

{   
   "message": "The document with ID: '00T3000023D23' could not be found.", 
   "success": false
}