CDN

The CalmLens CDN serves retained asset content, previews and derived versions from https://cdn.calmlens.com/v1. Create a signed URL with the public API to give an untrusted client time-limited access to one private resource.

Guide: Delivering assets.

Authentication: public assets need no authentication. Private assets need a signed URL, an owner's portal session, or an API key with Download assets (assets:download) in the X-Api-Key header. Creating a signed URL uses a project API key on https://api.calmlens.com/v1. See Authentication → CDN access.

Endpoints

EndpointDescription
POST /assets/:assetId/signed-urlCreate a short-lived signed CDN URL for an asset

CDN URL formats

All paths are relative to https://cdn.calmlens.com/v1. assetIdentifier is the asset ID or its externalId.

URLReturns
GET /assets/:projectId/:assetIdentifier/contentThe original stored file.
GET /assets/:projectId/:assetIdentifier/previewA browser-friendly preview. HEIC and HEIF images are converted to WebP.
GET …/content/@:lensIdentifierThe content with a named lens applied, such as @thumbnail.
GET …/content/imageTransform[format=png,width=1024]The content with a direct transform applied.
GET …?exp=:expiresAt&sig=:signatureAny of the above, authorized by a signed URL.

Lens and transform selectors work on /preview too. Only assets whose content was retained (processingOptions.keepContentAfterProcessing: true) and that are not rejected, failed, safety-held or removed are served. The CDN checks this on every request, including requests answered from its cache, so a change takes effect within seconds. Unavailable private assets return 404; assets blocked by their status return 403 asset/not-available. Invalid transform selectors return 400 asset/invalid-transform.

const response = await client.cdn.serve({
  assetIdentifier: assetId,
});

Original content

Use GET /assets/:projectId/:assetIdentifier/content for original bytes.

Previews

Use GET /assets/:projectId/:assetIdentifier/preview for a browser-friendly representation.

For named lenses, one-off transform selectors, and supported image options, see Lenses & Transformation.

CDN errors

StatusCodeDescription
403asset/not-availableThe asset is blocked by its status, a safety hold, or unavailable stored content.
400asset/invalid-transformThe transform selector is malformed or names an unknown transform type.
400asset/invalid-transform-optionsThe transform options do not match the supported option schema.

Transform processing failures can also return 500 for the availability error above.

The signed URL object

FieldTypePresenceDescription
urlstringRequiredSigned CDN URL, including the exp and sig query parameters
expiresAtnumberRequiredWhen the URL expires, in milliseconds since the Unix epoch

Endpoint details

Create Asset Signed URL

Create a short-lived signed CDN URL for an asset

OpenAPI YAML
POST
https://api.calmlens.com/v1/assets/
/signed-url
import { CalmLensClient } from "@calmlens/sdk";

const client = new CalmLensClient({
  apiKey: "your-api-key",
  projectId: "your-project-id"
});

const response = await client.assets.createSignedUrl({
  "resource": "content",
  "expiresInSeconds": 900,
  "assetId": "987fcdeb-51a2-43d7-b890-123456789abc"
});

Request Body

Edit any value to update the generated request examples.

enumRequired
Which CDN resource to sign
Allowed values
contentpreview
numberRequired
Lifetime of the URL in seconds, from 1 second to 24 hours
string (optional)Optional
Lens identifier to apply, such as thumbnail. Do not combine with transform.
string (optional)Optional
Direct transform selector, such as imageTransform[format=png,width=1024]. Do not combine with lens.

Response

urlstringRequired
Signed CDN URL, including the exp and sig query parameters
expiresAtnumberRequired
When the URL expires, in milliseconds since the Unix epoch

Error Codes

401auth/missing-token
Authentication required. Send your project API key in the X-Api-Key header.
401auth/invalid-api-key
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403auth/project-mismatch
This API key belongs to a different project. Use a key created for the project that owns this resource.
404asset/not-found
Asset not found
404project/not-found
Project not found

Signing in

Signing out

Cookies on CalmLens

We use essential cookies to keep you signed in and the site secure. With your permission, we'll also use functional cookies to remember preferences such as your layout and documentation language, and to offer Google One Tap sign-in. We don't use analytics or advertising cookies. Manage cookies