Overview
Security and compliance documentation often lives across disparate and niche repositories where native file integration often do not exist.
With the SafeBase documents API, organizations can now integrate these repositories with SafeBase to keep documents in sync without managing files across multiple systems.
This API workflow allows teams to programmatically add, replace, and delete the documentation in SafeBase.
Guide
This guide outlines the high-level workflows for uploading, replacing, and removing documents using our documents endpoints.
API documentation for all of SafeBase’s endpoints here.
Generate an API key
Admins can follow this guide to generate an API key.
Upload a New Document
SafeBase uses a secure, three step process for handling file uploads. Instead of sending the file data directly to our API, users will first request a secure upload location and then confirm the creation of the document.
The Workflow
Request an Upload URL
Call the POST /documents/upload endpoint with the file’s metadata (name, size, and type).
The API will return a temporary fileId and a secure signedUrl
Upload the File
Send the actual file binary to the signedUrl provided in the previous step.
Include the appropriate headers provided from the response of the previous API response.
Create the Record
Once the file is uploaded, call PUT /documents/upload using the fileId received earlier.
This finalizes the process and creates the document record in SafeBase.
When creating the document record in SafeBase users can optionally add metadata to that document. See our API documentation for more details.
Replacing an Existing File
To replace an existing document, e.g., replacing "Security Policy v1" with "Security Policy v2", without creating a duplicate record or breaking existing links, follow a similar flow to uploading a new file.
The Workflow
Upload the New Version
Just like a new upload, call POST /documents/upload to get a new signedUrl, and upload the new file binary to that location.
Update the Record
Call the PUT /documents/upload endpoint.
Crucial Step
In the request body, include the replacementDocumentId field containing the ID of the existing document that is to be overwritten.
This tells SafeBase to swap the underlying file while keeping the original document ID and history intact.
Deleting a Document
If a document is no longer needed, it can permanently remove it from the Trust Center using its unique ID.
The Workflow:
Call the DELETE /document/{id} endpoint, replacing {id} with the unique identifier of the document that is to be removed.
Video Walkthrough
A walkthrough of the Documents APIs can be found here here.
