Large Files Service

What it is

The Large Files Service (https://files.3b4sf.com, also https://files.3bapi.com) reads and writes Salesforce ContentVersion files that are too big to move through Apex. Apex is capped on heap size and string length, so whenever a 3B app needs to read or write a file larger than roughly 2 to 3 MB, it delegates to this service, which streams the bytes directly between the caller and Salesforce.

It is used by 3B Forms, 3B Portals, 3B Onboarding, 3B CLM and 3B WFM.

Authentication

Calls authenticate with a 3B sessionKey, exchanged for a live token at the Authorization Server. See the sessionKey model.

Endpoints

Method + path Purpose
POST /v1/fileUpload Upload a file (multipart/form-data, streamed). Current path.
GET /v1/getFile Download a file as a binary stream. Current path.
GET /v1/file Legacy download. Returns the file base64-encoded in JSON.
POST /v1/file Legacy upload with a JSON ContentVersion body. To be deprecated; use /v1/fileUpload.
GET /health Health check.

Upload: POST /v1/fileUpload

Send the file as multipart/form-data with the file under the field name file. Metadata travels in request headers.

POST https://files.3b4sf.com/v1/fileUpload
Content-Type: multipart/form-data; boundary=...
x-namespace: b3f
x-session-key: <sessionKey>
x-title: Signed Contract.pdf
x-first-publish-location-id: <record-id>
Header Required Purpose
x-namespace yes The calling app's package namespace (for example b3f, b3o).
x-session-key yes 3B sessionKey for the org.
x-title yes File title / PathOnClient.
x-first-publish-location-id one of these two Record to attach a new file to (FirstPublishLocationId).
x-content-document-id one of these two Existing ContentDocumentId to add a new version to instead.
x-content-location no ContentVersion ContentLocation. Defaults to S.
x-origin no ContentVersion Origin. Defaults to C.

Provide either x-first-publish-location-id (new file on a record) or x-content-document-id (new version of an existing file), plus the file part.

The service streams the upload to Salesforce, so the file size is not limited by Apex heap. When a publish location is given, the file is shared to that record. It returns the Salesforce response (including the new record id).

Download: GET /v1/getFile

GET https://files.3b4sf.com/v1/getFile?contentVersionId=<content-version-id>&sessionKey=<sessionKey>
Query param Required Purpose
contentVersionId yes The ContentVersion to download.
sessionKey yes 3B sessionKey for the org.

The response is the raw file streamed back (application/octet-stream), with no base64 encoding.

Legacy download: GET /v1/file

Returns the file base64-encoded inside JSON: { "success": true, "responseObject": "<base64>" }. Takes contentVersionId and sessionKey. Prefer /v1/getFile for large files, since base64 inflates the size by about 33%.

Common errors

Message Cause Fix
Missing or invalid multipart/form-data content type Upload wasn't sent as multipart. Send multipart/form-data with the file under field file.
Missing required headers. Provide: x-namespace, x-session-key and x-title One of the required upload headers is missing. Add all three headers.
Missing required headers. Provide: x-first-publish-location-id or x-content-document-id Neither target header was set. Provide one of the two.
Missing required file content, or file field name ("file"). No file part, or it used the wrong field name. Send the file under the field name file.
Missing required parameters. Provide: contentVersionId and sessionKey A download was called without both params. Include both query params.
Failed to authorize request: … The sessionKey is invalid/expired or the org isn't onboarded. Refresh the sessionKey; confirm the org is onboarded.
Failed to save file: … (<statusText>) Salesforce rejected the write (permissions, invalid target id, storage limit). Check the integration user's file permissions and the target record id.
Failed to fetch file: … (<statusText>) The ContentVersion id is wrong or not visible to the integration user. Verify the contentVersionId and access.