CloudPDF
DocsPricing
Start building

Insert pages from a PDF

POST/v1/docs/{docId}/layers/{layerName}/pages/insertv3.0.0-next.15

Copy every page of an uploaded PDF into the document at an index.

Multipart: a JSON `body` part `{"position"?: PagePosition, "resources": {"source": "<key>"}}` (position omitted → the end), and the standalone PDF whose pages are copied in as the part `resource:<key>`. The inserted copies get fresh page object numbers, returned in insertion order.

Authentication#

Any one of these credentials is accepted.

API token

The deployment's static root credential (CLOUDPDF_API_AUTH_TOKENS), valid on every surface.

Document token

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).

Document capabilitydoc.pages.assemble

Parameters#

docIdpathstringrequired
layerNamepathstringrequired
X-Document-Passwordheaderstring

Base64-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.

Idempotency-Keyheaderstring

Names the change: 1 to 255 printable ASCII characters. A retry under the same key on the same layer answers with what the first request committed, and changes nothing.

Request body#

multipart/form-dataobjectrequired
filestring<binary>required

SDK 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#

200OK
application/jsonDocPagesInsert200Response
insertedPagesPageRef[]
kind"objectNumber"
objectNumberinteger
layoutobject
pageCountinteger
pagesobject[]
indexinteger
refPageRef
kind"objectNumber"
objectNumberinteger
labelstring
sizeobject
widthnumber
heightnumber
rotation0 | 90 | 180 | 270
userUnitnumber
tabOrder"rows" | "columns" | "structure" | "annotations" | "widgets"
boxesobject
mediaobject
cropobject
bleedobject
trimobject
artobject
pdfCropBoxobject
leftnumber
bottomnumber
rightnumber
topnumber
actionsPdfPageActionsoptional
openPdfActionTreeoptional
closePdfActionTreeoptional
namedPagesobject[]
namestring
target"page" | "template" | "dangling"
kind =
kind"page"
pagePageRef
metaMutationMeta
affectedPagesPageRef[]
kind"objectNumber"
objectNumberinteger
cacheDeltaCacheDelta
opIdstring
undoableboolean
400Bad request
application/jsonDocPagesInsert400Response
404Not found
application/jsonDocPagesInsert404Response
defaultError
application/jsonEngineErrorPayload
name"EngineError"
code"Unknown" | "InvalidArg" | "DocNotOpen" | "DocOpenFailed" | "DocPasswordRequired" | "DocPasswordIncorrect" | "SharePasswordRequired" | "Aborted" | "Network" | "Unauthenticated" | "Forbidden" | "NotFound" | "WireFormat" | "RuntimeUnavailable" | "LayerVersionConflict" | "NotImplemented" | "MalformedPdf" | "SigningPending" | "SigningExpired" | "SigningVersionMismatch" | "SignatureRefused" | "ProtectedDocument" | "StaleBase" | "PayloadTooLarge" | "ObjectNumberUnavailable" | "LayerFull" | "ChangeConflict" | "UndoUnavailable" | "IdempotencyKeyReused"
messagestring
detailsobjectoptional