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 under its own /v1/tenants/{tenantId}/ subtree — the path tenant must equal the token's tenant_id. 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.
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({
baseUrl: "https://yourhost.com/path/to/api",
token: "<token>",
});
await client.documents.importFrom({
tenantId: "tenantId",
source: {
kind: "url",
url: "url"
}
});Responses#
application/jsonDocumentsImportFrom200Responsetag"imported" | "deduped" | "accepted"documentobjectidstringtenantIdstringstate"pending" | "ready" | "failed" | "deleting"baseShastringstorageSizeBytesnumbermetadataobjectidempotencyKeystringfailureReasonstringthumbnailState"pending" | "ready" | "locked" | "failed"optionalthumbnailUrlstringoptionalcreatedAtnumberupdatedAtnumbercreatedBystringapplication/jsonDocumentsImportFrom202Responsetag"imported" | "deduped" | "accepted"documentobjectidstringtenantIdstringstate"pending" | "ready" | "failed" | "deleting"baseShastringstorageSizeBytesnumbermetadataobjectidempotencyKeystringfailureReasonstringthumbnailState"pending" | "ready" | "locked" | "failed"optionalthumbnailUrlstringoptionalcreatedAtnumberupdatedAtnumbercreatedBystringapplication/jsonDocumentsImportFrom400Responseerrorobjectcodestringmessagestringapplication/jsonDocumentsImportFrom403Responseerrorobjectcodestringmessagestringapplication/jsonDocumentsImportFrom502Responseerrorobjectcodestringmessagestringapplication/jsonAdminErrorPayloaderrorobjectcodestringmessagestring