The PDF Engine (https://pdf.3bapi.com) renders a web page to a PDF with a
headless browser and uploads the result into a Salesforce org as a
ContentVersion (a file) linked to a record. It is used by 3B CLM to produce
generated documents, and is available to external developers building custom
Salesforce apps. Do not use the older https://www.3bapi.com host.
Generation is asynchronous: the API validates the request, enqueues a job,
and returns a jobId immediately. The PDF is then rendered and written to
Salesforce. There is no callback; the PDF appears on the target record when the
job completes.
Requests authenticate with a 3B sessionKey. The org must be onboarded on the Authorization Server first. See the sessionKey model.
| Method + path | Status | Notes |
|---|---|---|
POST /v2/html-to-pdf/async |
Current | Requires sessionKey, recordId, file.url. Use this. |
POST /v1/html-to-pdf/async |
Removed | Returns HTTP 410 Gone. Use v2. |
POST /v1/html-to-pdf |
Removed | Returns an error directing you to the async path. Use v2. |
GET /health |
Health check. |
POST https://pdf.3bapi.com/v2/html-to-pdf/async
Content-Type: application/json
{
"sessionKey": "<sessionKey>",
"recordId": "<record-id>",
"fileName": "Offer Letter.pdf",
"file": {
"url": "https://<your-site-domain>/apex/RenderDoc?id=<record-id>"
},
"options": { "format": "A4", "printBackground": true }
}
| Field | Required | Purpose |
|---|---|---|
sessionKey |
yes | 3B sessionKey for the target org. |
recordId |
yes | The Salesforce record the PDF is attached to (ContentVersion FirstPublishLocationId). |
file.url |
yes | Absolute http(s) URL the engine opens and renders. |
fileName |
no | Title/filename of the saved file. Defaults to unknown_file_name. |
options |
no | PDF options (see below). |
Response:
{ "success": true, "responseObject": { "jobId": "42" } }
file.urlmust be an absolutehttp(s)URL. A relative URL like/apex/RenderDoc?id=…is rejected; it usually means the org's Site base URL is not configured. Note the engine navigates to this URL as an unauthenticated browser, so the page must be reachable (e.g. a Visualforce page on a public Site, or a page that authorizes via its own URL parameters).
The engine renders the PDF, then saves it as a ContentVersion on recordId:
FirstPublishLocationId = recordId).ContentDocumentId reused) rather than a duplicate.options)All options are optional. printBackground is always on.
| Option | Type | Default | Description |
|---|---|---|---|
scale |
number | 1 |
Webpage render scale, between 0.1 and 2. |
displayHeaderFooter |
boolean | false |
Show header/footer templates. |
headerTemplate |
string | none | HTML for the header. Use classes date, title, url, pageNumber, totalPages to inject values. |
footerTemplate |
string | none | HTML for the footer; same class conventions as the header. |
printBackground |
boolean | true (always on) |
Print background graphics. |
landscape |
boolean | false |
Paper orientation. |
pageRanges |
string | all | Ranges to print, e.g. "1-5, 8, 11-13". |
format |
string | Letter |
Paper format (e.g. A4, Letter, Legal). Takes priority over width/height. |
width |
string | number | none | Paper width, accepts units (e.g. "210mm"). |
height |
string | number | none | Paper height, accepts units. |
margin |
object | none | { top, right, bottom, left }, each a value with units. |
preferCSSPageSize |
boolean | false |
Let the page's CSS @page size win over width/height/format. |
file object| Property | Description |
|---|---|
url |
Absolute public URL to render. Required. Raw HTML content is not supported. |
jobId.| Message | Cause | Fix |
|---|---|---|
Missing sessionKey in request |
No sessionKey on a v2 call. |
Include the org's sessionKey. |
Missing recordId in request |
No recordId. |
Provide the record to attach the PDF to. |
Missing file.url in request |
No file.url. |
Provide an absolute page URL. |
file.url must be an absolute http(s) URL — check the Site base URL configuration in the org |
A relative URL was sent. | Configure the org's Site base URL so it builds absolute URLs. |
Failed to authorize: … (during the job) |
The sessionKey is invalid/expired, or the org isn't onboarded. | Refresh the sessionKey; confirm the org is onboarded. |
Failed to generate PDF: … |
The engine couldn't load the page (unreachable URL, auth wall, timeout). | Make the render URL publicly reachable and self-authorizing. |
Failed to save PDF: … / Failed to create ContentVersion: … |
The org rejected the file write (permissions, invalid recordId, storage). |
Check the integration user's access and that recordId exists. |
This endpoint is no longer available. Use "/v1/html-to-pdf/async" |
Called the removed synchronous POST /v1/html-to-pdf. |
Use POST /v2/html-to-pdf/async. |