Insert pages from a PDF
Copy every page of an uploaded PDF into the document at an index.
Multipart mutation envelope: a `body` field holding `{"destIndex"?: number}` (omitted → append) plus a `resource:source` file part carrying the standalone PDF whose pages are copied in. The inserted copies get fresh page object numbers, returned in insertion order.
Authentication#
Any one of these credentials is accepted.
The deployment's static root credential (CLOUDPDF_API_AUTH_TOKENS), valid on every surface.
Doc-scoped JWT, valid only on the /v1/docs/{docId} subtree it names, gated by the capability scopes it carries (each operation's x-required-capability).
Parameters#
docIdpathstringrequiredlayerNamepathstringrequiredX-Document-PasswordheaderstringBase64-encoded password for an encrypted document. Valid only with the API token (403 anywhere else). An encrypted document answers 422 DocPasswordRequired when the header is absent. Viewer doc JWTs use the SDK password-session flow instead.
Request body#
multipart/form-dataobjectrequiredfilestring<binary>requiredSDK examples#
The selected SDK is remembered across the API reference. Values are examples; replace them with identifiers and input from your application.
import { CloudPDFClient } from "@cloudpdf/sdk";
const client = new CloudPDFClient({
baseUrl: "https://yourhost.com/path/to/api",
token: "<token>",
});
await client.doc.pages.insert({
file: fs.createReadStream("/path/to/your/file"),
docId: "docId",
layerName: "layerName"
});Responses#
application/jsonDocPagesInsert200ResponsemetaobjectaffectedPagesobject[]pageObjectNumberintegerrevisionobjectdocSessionIdstringpageObjectNumberintegergenerationintegerweakAnnotationState"unknown" | "known"kind"unknown"cacheDeltaobjectpreviousDocVersionintegerdocVersionintegerpagesobject[]pageObjectNumberintegercacheobjectapplication/jsonDocPagesInsert400Responsename"EngineError"code"Unknown" | "InvalidArg" | "DocNotOpen" | "DocOpenFailed" | "DocPasswordRequired" | "DocPasswordIncorrect" | "SharePasswordRequired" | "Aborted" | "Network" | "Unauthenticated" | "Forbidden" | "NotFound" | "WireFormat" | "RuntimeUnavailable" | "InvalidReference" | "WeakAnnotationSessionConflict" | "LayerVersionConflict" | "NotImplemented" | "MalformedPdf"messagestringdetailsobjectoptionalapplication/jsonDocPagesInsert404Responsename"EngineError"code"Unknown" | "InvalidArg" | "DocNotOpen" | "DocOpenFailed" | "DocPasswordRequired" | "DocPasswordIncorrect" | "SharePasswordRequired" | "Aborted" | "Network" | "Unauthenticated" | "Forbidden" | "NotFound" | "WireFormat" | "RuntimeUnavailable" | "InvalidReference" | "WeakAnnotationSessionConflict" | "LayerVersionConflict" | "NotImplemented" | "MalformedPdf"messagestringdetailsobjectoptionalapplication/jsonEngineErrorPayloadname"EngineError"code"Unknown" | "InvalidArg" | "DocNotOpen" | "DocOpenFailed" | "DocPasswordRequired" | "DocPasswordIncorrect" | "SharePasswordRequired" | "Aborted" | "Network" | "Unauthenticated" | "Forbidden" | "NotFound" | "WireFormat" | "RuntimeUnavailable" | "InvalidReference" | "WeakAnnotationSessionConflict" | "LayerVersionConflict" | "NotImplemented" | "MalformedPdf"messagestringdetailsobjectoptional