Skip to main content
Attaching a document requires three requests:
  1. request an upload URL;
  2. send the file to this URL;
  3. attach the file to a Bonx record.
The document then appears in the Files tab of the record.

1. Request an upload URL

Send the file name and MIME type to generatePresignedUrlUpload.
Variables
The response contains:
  • uploadUrl, the URL where you must send the file. It expires after 10 minutes;
  • fileName, the storage name created by Bonx. Keep this value for step 3.

2. Send the file

Send the file content with a PUT request to uploadUrl. Use the same Content-Type header as in step 1.
Do not add the Bonx token to this request. The upload URL already contains a temporary authorization.
Storage rejects the file if the Content-Type is different from the value used in step 1.

3. Attach the file to the record

Use insertFilesOne to create the link between the file and the record.
Variables
Set the variables as follows:
  • fileId: use the fileName received in step 1;
  • name: enter the name displayed in Bonx;
  • size: enter the file size in bytes;
  • recordId: enter the internal record ID;
  • recordType: enter the technical record type.

Available record types

recordType contains the plural technical name of the entity.

Find a record ID

A document usually contains the visible record number, such as REC-0412. Use this number to get the internal id.
Stop the process if the query returns no result. In this case, the document number does not match a receiving.
See the complete JavaScript example to automate these three requests.