Lenses

Use a project API key to create or update versioned lens definitions.

EndpointDescription
PUT /lenses/:lensIdentifierCreate a lens or update it with a version greater than the current version
PUT /projects/:projectId/lensesCreate lenses or update them with their next versions

The lens object

FieldTypePresenceDescription
idstringRequiredUnique lens ID
projectIdstringOptional, nullableID of the project that owns the lens; null for built-in lenses
userIdstringOptional, nullableID of the user whose account created the lens
versionintegerOptionalDefinition version. Updates must use a greater version; it is part of the CDN cache key. Default: 1.
identifierstringRequiredName used in CDN URLs after @. Lowercase letters, numbers and hyphens, at most 50 characters.
namestringRequiredDisplay name
descriptionstringOptional, nullableOptional description of what the lens produces
type"image" | "video" | "audio" | "document" | "website"RequiredAsset type the lens applies to
activebooleanRequiredWhether the CDN serves the lens
transformsobject[]Optional, nullableTransforms applied in order to produce the derived asset
transforms[].typestringRequiredTransform type, such as imageTransform
transforms[].optionsanyRequiredOptions for the transform type, such as width and format
createdAtintegerRequiredWhen the lens was created, in milliseconds since the Unix epoch
updatedAtintegerOptionalWhen the lens was last updated, in milliseconds since the Unix epoch

Endpoint details

Ensure Lens

Create a lens or update it with a version greater than the current version

OpenAPI YAML
PUT
https://api.calmlens.com/v1/lenses/
import { CalmLensClient } from "@calmlens/sdk";

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

const response = await client.ensureLens({
  "identifier": "thumbnail",
  "name": "Thumbnail",
  "type": "image",
  "active": true,
  "version": 1,
  "transforms": [
    {
      "type": "imageTransform",
      "options": {
        "fit": "scale-down",
        "width": 640,
        "format": "webp"
      }
    }
  ]
});

Request Body

Edit any value to update the generated request examples.

stringRequired
Name used in CDN URLs after @. Lowercase letters, numbers and hyphens, at most 50 characters.
stringRequired
Display name
enumRequired
Asset type the lens applies to
Allowed values
imagevideoaudiodocumentwebsite
booleanRequired
Whether the CDN serves the lens
numberRequired
Definition version. Updates must use a greater version; it is part of the CDN cache key.
string (optional)Optional
Optional description of what the lens produces

Response

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.
409lens/version-conflict
Lens updates require a version greater than the current version.

Ensure Lenses

Create lenses or update them with their next versions

OpenAPI YAML
PUT
https://api.calmlens.com/v1/projects/
/lenses
import { CalmLensClient } from "@calmlens/sdk";

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

const response = await client.ensureLenses({
  "lenses": [
    {
      "identifier": "thumbnail",
      "name": "Thumbnail",
      "type": "image",
      "active": true,
      "version": 1,
      "transforms": [
        {
          "type": "imageTransform",
          "options": {
            "fit": "scale-down",
            "width": 640,
            "format": "webp"
          }
        }
      ]
    }
  ]
});

Request Body

Edit any value to update the generated request examples.

Response

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.
409lens/version-conflict
Lens updates require a version greater than the current version.

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