CloudPDF
DocsPricing
Start building

Import document

POST/v1/tenants/{tenantId}/documents/importv3.0.0-next.9

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.

API token

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

Tenant token

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.

Required scopedocs.create

Parameters#

tenantIdpathstringrequired

Request body#

application/jsonDocumentsImportFromRequestrequired
source"url" | "connection"required

Where CloudPDF pulls the bytes from. The two shapes differ in WHO supplies the authority to read, not in which storage vendor holds the file.

kind =

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"required
urlstring<uri>required

The URL to fetch. Must be allowed by the deployment import policy (scheme, network range, size) and must declare a length.

expectedobject

Integrity pins, enforced when present. When absent, the server-observed values become authoritative.

sizeBytesinteger

Checked against the source's declared Content-Length before the transfer.

sha256string

Checked against the server-observed digest after the transfer. Required when dedupMode is reuse-existing.

metadataobject
idempotencyKeystring

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

docIdstring
mode"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#

200OK
application/jsonDocumentsImportFrom200Response
tag"imported" | "deduped" | "accepted"
documentobject
idstring
tenantIdstring
state"pending" | "ready" | "failed" | "deleting"
baseShastring
storageSizeBytesnumber
metadataobject
idempotencyKeystring
failureReasonstring
thumbnailState"pending" | "ready" | "locked" | "failed"optional
thumbnailUrlstringoptional
createdAtnumber
updatedAtnumber
createdBystring
202Response
application/jsonDocumentsImportFrom202Response
tag"imported" | "deduped" | "accepted"
documentobject
idstring
tenantIdstring
state"pending" | "ready" | "failed" | "deleting"
baseShastring
storageSizeBytesnumber
metadataobject
idempotencyKeystring
failureReasonstring
thumbnailState"pending" | "ready" | "locked" | "failed"optional
thumbnailUrlstringoptional
createdAtnumber
updatedAtnumber
createdBystring
400Bad request
application/jsonDocumentsImportFrom400Response
errorobject
codestring
messagestring
403Forbidden
application/jsonDocumentsImportFrom403Response
errorobject
codestring
messagestring
502Response
application/jsonDocumentsImportFrom502Response
errorobject
codestring
messagestring
defaultError
application/jsonAdminErrorPayload
errorobject
codestring
messagestring