Create grant
Create a standing grant for one document — the no-backend embed credential.
The returned id is what a link page or an embed opens. Its scope gives only document permissions the caller holds itself, as tokens.issue does. Mounted only when the deployment can sign (HS256 mode) — exchange mints session JWTs, so grants exist only where minting does.
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/jsonGrantsCreateRequestrequireddocIdstringrequirednamestringlayerMode"shared" | "per-visitor"layerNamestringkeepVisitorLayersbooleanvisitorIdleSecondsintegervisitorIdentityobjectfieldsobjectrequireddisplayName"required" | "optional"email"required" | "optional"title"required" | "optional"organization"required" | "optional"organizationalUnit"required" | "optional"ask"on-open" | "before-first-change"requiredpurposestringprivacyUrlstring<uri>identityIdentityscopestring[]requiredoriginsstring[]passphrasestringsessionTtlSecondsintegerexpiresAtstring<date-time>A complete body with every required field. Strings stand in for your own values.
{
"docId": "docId",
"scope": [
"scope"
]
}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({
token: "<token>",
});
await client.grants.create({
tenantId: "tenantId",
docId: "docId",
scope: ["scope"]
});Responses#
application/jsonGrantsCreateResponsegrantobjectidstringtenantIdstringdocIdstringnamestringlayerMode"shared" | "per-visitor"layerNamestringkeepVisitorLayersbooleanvisitorIdleSecondsintegervisitorIdentityobjectfieldsobjectdisplayName"required" | "optional"optionalemail"required" | "optional"optionaltitle"required" | "optional"optionalorganization"required" | "optional"optionalorganizationalUnit"required" | "optional"optionalask"on-open" | "before-first-change"purposestringoptionalprivacyUrlstring<uri>optionalidentityIdentityscopestring[]originsstring[]passphraseProtectedbooleansessionTtlSecondsintegerdisabledbooleanarchivedAtstring<date-time>expiresAtstring<date-time>exchangeCountintegerlastExchangedAtstring<date-time>createdBystringcreatedAtstring<date-time>updatedAtstring<date-time>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.
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.