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
| Endpoint | Description |
|---|---|
POST / | Create 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.
| URL | Returns |
|---|---|
GET / | The original stored file. |
GET / | A browser-friendly preview. HEIC and HEIF images are converted to WebP. |
GET …/ | The content with a named lens applied, such as @thumbnail. |
GET …/ | The content with a direct transform applied. |
GET …?exp=:expiresAt&sig=:signature | Any 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 / for original bytes.
Previews
Use GET / for a browser-friendly representation.
For named lenses, one-off transform selectors, and supported image options, see Lenses & Transformation.
CDN errors
| Status | Code | Description |
|---|---|---|
| 403 | asset/not-available | The asset is blocked by its status, a safety hold, or unavailable stored content. |
| 400 | asset/invalid-transform | The transform selector is malformed or names an unknown transform type. |
| 400 | asset/invalid-transform-options | The 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
| Field | Type | Presence | Description |
|---|---|---|---|
url | string | Required | Signed CDN URL, including the exp and sig query parameters |
expiresAt | number | Required | When the URL expires, in milliseconds since the Unix epoch |
Endpoint details
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"
});
Response
exp and sig query parametersError Codes
auth/missing-tokenauth/invalid-api-keyauth/project-mismatchasset/not-foundproject/not-found