Import document
Server-side pull: fetch a PDF from a caller-supplied URL (e.g. a presigned object-store GET) or an operator-registered storage connection into CloudPDF-owned storage, verify it, and commit it.
Default mode is synchronous and bounded: the response returns only after the transfer verified and committed (or failed). mode=async (connection sources only) answers 202 immediately and an in-process worker performs the transfer with leased, fenced retries; poll the document until ready/failed. The deployment import policy gates scheme, network range, and size; sources must declare a length. CloudPDF copies and owns the bytes — the source is never referenced in place. A 502 marks a retryable upstream failure: retry with the same idempotencyKey to resume the same document. URL sources are capabilities and never echoed back. Connection sources name operator-registered storage (bucket/prefix scope, allowed credential classes, and tenant bindings are deployment configuration); `revision` is provider-interpreted (S3 VersionId, GCS generation, Azure version id).
Authentication#
Any one of these credentials is accepted.
The deployment's static root credential (CLOUDPDF_API_AUTH_TOKENS), valid on every surface.
Delegated tenant JWT, valid only for its own tenant: under /v1/tenants/{tenantId}/ the path tenant must equal the token's tenant_id, and on /v1/docs/{docId} the document must belong to that tenant and the token's scope must hold the operation's document permissions, as a document token does. For servers; browsers get document tokens. Doc-scoped viewer tokens are rejected on every admin route.
Parameters#
tenantIdpathstringrequiredRequest body#
application/jsonDocumentsImportFromRequestrequiredsource"url" | "connection"requiredWhere CloudPDF pulls the bytes from. The two shapes differ in who supplies the authority to read, not in which storage vendor holds the file.
The caller supplies the authority: a presigned S3/GCS/Azure/R2/MinIO GET, or any HTTPS endpoint the deployment import policy allows. The URL is a capability — treat it as a secret. CloudPDF never echoes its query string back in errors, logs, or stored failure reasons.
kind"url"requiredurlstring<uri>requiredThe URL to fetch. Must be allowed by the deployment import policy (scheme, network range, size) and must declare a length.
expectedobjectIntegrity pins, enforced when present. When absent, the server-observed values become authoritative.
sizeBytesintegerChecked against the source's declared Content-Length before the transfer.
sha256stringChecked against the server-observed digest after the transfer. Required when dedupMode is reuse-existing.
namestringWhat people call the document: shown in dashboards, searched and sorted by. 1 to 255 characters, no control characters, no leading or trailing whitespace. Names need not be unique.
folderIdstringA folder id, or root for the top level.
metadataobjectidempotencyKeystringRetrying with the same key resumes the same document rather than importing a second copy — including after a 502.
dedupMode"always-create" | "reuse-existing"always-create (default) creates a new document every time. reuse-existing returns a document that already holds the same content instead of storing it twice.
docIdstringmode"sync" | "async"sync (default) holds the response open for the whole transfer. async answers 202 with the document pending and transfers in the background; it requires a connection source, and filesystem connections additionally require expected.sha256.
A complete body for each shape. Strings stand in for your own values.
{
"source": {
"kind": "url",
"url": "url"
}
}SDK examples#
The selected SDK is remembered across the API reference. Values are examples; replace them with identifiers and input from your application.
This body offers a choice, and the example takes one branch: it sends source as url. The request body above carries the other shape — connection.
import { CloudPDFClient } from "@cloudpdf/sdk";
const client = new CloudPDFClient({
token: "<token>",
});
await client.documents.importFrom({
tenantId: "tenantId",
source: {
kind: "url",
url: "url"
}
});Responses#
application/jsonDocumentsImportFrom200Responsestatus"imported" | "deduped" | "accepted"documentobjectidstringtenantIdstringnamestringfolderIdstringThe folder the document is in, or root.
state"pending" | "ready" | "failed" | "deleting"baseSha256stringsizeBytesintegermetadataobjectidempotencyKeystringfailureReasonstringthumbnailState"pending" | "ready" | "locked" | "failed"thumbnailUrlstringcreatedAtstring<date-time>updatedAtstring<date-time>createdBystringapplication/jsonDocumentsImportFrom202Responsestatus"imported" | "deduped" | "accepted"documentobjectidstringtenantIdstringnamestringfolderIdstringThe folder the document is in, or root.
state"pending" | "ready" | "failed" | "deleting"baseSha256stringsizeBytesintegermetadataobjectidempotencyKeystringfailureReasonstringthumbnailState"pending" | "ready" | "locked" | "failed"thumbnailUrlstringcreatedAtstring<date-time>updatedAtstring<date-time>createdBystringapplication/jsonErrorResponseerrorEngineErrorcode"Unknown" | "InvalidArg" | "DocNotOpen" | "DocOpenFailed" | "DocPasswordRequired" | "DocPasswordIncorrect" | "GrantPassphraseRequired" | "Aborted" | "Network" | "Unauthenticated" | "Forbidden" | "NotFound" | "WireFormat" | "RuntimeUnavailable" | "LayerVersionConflict" | "NotImplemented" | "MalformedPdf" | "SigningPending" | "SigningExpired" | "SigningVersionMismatch" | "SignatureRefused" | "ProtectedDocument" | "PayloadTooLarge" | "ObjectNumberUnavailable" | "LayerFull" | "ChangeConflict" | "UndoUnavailable" | "IdempotencyKeyReused" | "LayerDeleted" | "VisitorIdentityRequired" | "Conflict" | "EngineBusy" | "EngineRestarting" | "DocumentQuarantined" | "ThumbnailNotReady" | "TooManyRequests" | "GrantExpired" | "OriginRequired" | "OriginNotAllowed" | "FeatureNotEnabled" | "FeatureStopped" | "LicenseInvalid" | "LicenseUsageLimit" | "UpstreamError"Why the request failed. A newer server can add codes: read one your client doesn't know as `Unknown`.
messagestringdetailsobjectoptionalWhat a code carries besides its message, as each code says.
application/jsonErrorResponseerrorEngineErrorcode"Unknown" | "InvalidArg" | "DocNotOpen" | "DocOpenFailed" | "DocPasswordRequired" | "DocPasswordIncorrect" | "GrantPassphraseRequired" | "Aborted" | "Network" | "Unauthenticated" | "Forbidden" | "NotFound" | "WireFormat" | "RuntimeUnavailable" | "LayerVersionConflict" | "NotImplemented" | "MalformedPdf" | "SigningPending" | "SigningExpired" | "SigningVersionMismatch" | "SignatureRefused" | "ProtectedDocument" | "PayloadTooLarge" | "ObjectNumberUnavailable" | "LayerFull" | "ChangeConflict" | "UndoUnavailable" | "IdempotencyKeyReused" | "LayerDeleted" | "VisitorIdentityRequired" | "Conflict" | "EngineBusy" | "EngineRestarting" | "DocumentQuarantined" | "ThumbnailNotReady" | "TooManyRequests" | "GrantExpired" | "OriginRequired" | "OriginNotAllowed" | "FeatureNotEnabled" | "FeatureStopped" | "LicenseInvalid" | "LicenseUsageLimit" | "UpstreamError"Why the request failed. A newer server can add codes: read one your client doesn't know as `Unknown`.
messagestringdetailsobjectoptionalWhat a code carries besides its message, as each code says.
application/jsonErrorResponseerrorEngineErrorcode"Unknown" | "InvalidArg" | "DocNotOpen" | "DocOpenFailed" | "DocPasswordRequired" | "DocPasswordIncorrect" | "GrantPassphraseRequired" | "Aborted" | "Network" | "Unauthenticated" | "Forbidden" | "NotFound" | "WireFormat" | "RuntimeUnavailable" | "LayerVersionConflict" | "NotImplemented" | "MalformedPdf" | "SigningPending" | "SigningExpired" | "SigningVersionMismatch" | "SignatureRefused" | "ProtectedDocument" | "PayloadTooLarge" | "ObjectNumberUnavailable" | "LayerFull" | "ChangeConflict" | "UndoUnavailable" | "IdempotencyKeyReused" | "LayerDeleted" | "VisitorIdentityRequired" | "Conflict" | "EngineBusy" | "EngineRestarting" | "DocumentQuarantined" | "ThumbnailNotReady" | "TooManyRequests" | "GrantExpired" | "OriginRequired" | "OriginNotAllowed" | "FeatureNotEnabled" | "FeatureStopped" | "LicenseInvalid" | "LicenseUsageLimit" | "UpstreamError"Why the request failed. A newer server can add codes: read one your client doesn't know as `Unknown`.
messagestringdetailsobjectoptionalWhat a code carries besides its message, as each code says.
application/jsonErrorResponseerrorEngineErrorcode"Unknown" | "InvalidArg" | "DocNotOpen" | "DocOpenFailed" | "DocPasswordRequired" | "DocPasswordIncorrect" | "GrantPassphraseRequired" | "Aborted" | "Network" | "Unauthenticated" | "Forbidden" | "NotFound" | "WireFormat" | "RuntimeUnavailable" | "LayerVersionConflict" | "NotImplemented" | "MalformedPdf" | "SigningPending" | "SigningExpired" | "SigningVersionMismatch" | "SignatureRefused" | "ProtectedDocument" | "PayloadTooLarge" | "ObjectNumberUnavailable" | "LayerFull" | "ChangeConflict" | "UndoUnavailable" | "IdempotencyKeyReused" | "LayerDeleted" | "VisitorIdentityRequired" | "Conflict" | "EngineBusy" | "EngineRestarting" | "DocumentQuarantined" | "ThumbnailNotReady" | "TooManyRequests" | "GrantExpired" | "OriginRequired" | "OriginNotAllowed" | "FeatureNotEnabled" | "FeatureStopped" | "LicenseInvalid" | "LicenseUsageLimit" | "UpstreamError"Why the request failed. A newer server can add codes: read one your client doesn't know as `Unknown`.
messagestringdetailsobjectoptionalWhat a code carries besides its message, as each code says.