API reference

Use the REST API to moderate content, read decisions, organise assets and create CDN links. Endpoint cards include parameters, schemas, errors and code samples. For integration steps, start with the quick start or moderation guide.

Base URLs

ServiceBase URL
REST APIhttps://api.calmlens.com/v1
CDNhttps://cdn.calmlens.com/v1
MCP serverhttps://api.calmlens.com/mcp

Request and response bodies are JSON unless an endpoint says otherwise, and timestamps are milliseconds since the Unix epoch. The full API is also available as an OpenAPI document. AI assistants reach the same endpoints as tools through the MCP server; see MCP and OAuth.

Authentication

Authenticate project API requests with a project API key in the X-Api-Key header:

X-Api-Key: your-api-key

The GET health check needs no authentication. Upload-preset endpoints use an upload token instead, or accept uploads without a token when the preset is open to anyone.

Keep API keys on your server. Do not expose them in browser code or public client bundles. Each key belongs to one project and grants only the permissions you choose when you create it; see Authentication. Browsers and other untrusted clients should load private assets through signed URLs.

Conventions

  • IDs. Resources are addressed by their IDs. Each ID is a prefix for its type, an underscore and letters and digits, such as proj_8fK2mQx7Lp4NvB3tRz9Y for a project, asset_5Gm2Rk8XqT3wLp9VbN4c for an asset and evt_7Lm3Xq8Rk2Vt9Wb4Np5C for an event. Treat IDs as opaque, case-sensitive strings: store them whole, don't parse them and don't rely on their length. Assets can also carry your own externalId, which the CDN accepts in place of the asset ID.
  • Pagination. Every list takes an optional cursor and a pageSize from 1 to 100 (default 50), and returns items, nextCursor and hasMore. Pass nextCursor as the next request’s cursor until hasMore is false. Lists that can be sorted take sort, a comma-separated list of fields, each descending when prefixed with -, such as -createdAt,id. The events feed always returns a nextCursor to keep for later events, and search returns its best matches without a cursor. See Pagination.
  • Filtering. The asset list accepts an RSQL-style filter. See Asset filters.
  • Query values. List-valued query parameters are comma-separated, such as types=asset.blocked,asset.purged, and structured ones are URL-encoded JSON. See Query values.
  • Errors. Failed requests return an HTTP error status with a JSON body of code, message, requestId and details. Handle errors by code; each endpoint card lists the codes it can return. See Error handling.
  • Request IDs. Every response carries an X-Request-Id header, and error bodies repeat it as requestId. Include it when you contact support about a request.
  • Idempotency. Asset uploads and upload parts accept an Idempotency-Key header, so a retry after a timeout returns the first response instead of creating a second asset. See Retrying requests safely.
  • Rate limits. CalmLens does not publish a general requests-per-second limit. Throttled requests return 429 with a Retry-After header. Running out of free uploads returns 403 usage/free-uploads-exhausted, and oversized files return 413 upload/too-large.
  • SDKs. The CalmLens SDKs wrap these endpoints, handle authentication and uploads, and return typed errors.

Compatibility

The /v1 API changes only in ways that keep working integrations working. Build your client to accept these additions, which can arrive at any time without a new version:

  • new endpoints, and new optional query parameters, body fields and headers;
  • new properties in response bodies, webhook bodies and nested objects;
  • new values in response enums, such as statuses, asset types, categories and removal reasons;
  • new event types and event facts;
  • new error codes on any endpoint, so handle a code you don't recognise by its HTTP status.

Within /v1, CalmLens doesn't remove or rename endpoints, fields or enum values, change a field's type, make an optional input required or change what an existing code means. A change like that comes with a new major version, such as /v2, which runs alongside /v1.

When something in /v1 is deprecated, the changelog and the endpoint's reference say so and name its replacement, and it keeps working for at least 12 months. Message text, ID lengths and the order of object properties aren't part of the contract.

Preview features

Endpoints and fields marked Preview in this reference and in the OpenAPI document (x-calmlens-preview) are outside this promise: they can change or be removed without a deprecation period while their design settles.

All endpoints

Assets

EndpointDescription
Upload
POST /projects/:projectId/assetsUpload a new asset to a project.
POST /projects/:projectId/assetsUpload a file by sending its raw bytes as the request body, with the X-CalmLens-Upload: content header and the file's Content-Type.
POST /projects/:projectId/assetsStart a multipart upload by streaming the first part's raw bytes as the request body, with the X-CalmLens-Upload: part header and the file's Content-Type.
POST /assets/:assetId/partUpload a sequential part for an in-progress asset upload.
Browser uploads
POST /upload-presets/:uploadPresetId/assetsUpload a file from a browser or app through an upload preset, without an API key.
POST /upload-presets/:uploadPresetId/assetsUpload a file through an upload preset by sending its raw bytes as the request body, with the X-CalmLens-Upload: content header and the file's Content-Type.
POST /upload-presets/:uploadPresetId/assets/:assetId/partUpload the next part of a multipart upload started through an upload preset.
GET /upload-presets/:uploadPresetId/assets/:assetIdCheck an upload made through an upload preset.
Read and review
GET /projects/:projectId/assetsList a page of the project's assets, optionally in one folder or matching a filter
GET /projects/:projectId/assets/searchSearch accessible assets by keyword or natural language.
GET /assets/:assetIdGet a single asset by ID
GET /assets/:assetId/childrenGet child assets of a parent asset
GET /projects/:projectId/assets/:assetId/timelinePage through every segment of an audio or video asset's findings timeline, in time order.
POST /assets/:assetId/retryProcess an asset whose classification.status is failed again.
POST /assets/:assetId/explainComplete the policy evidence behind an asset's moderation decision.
POST /assets/:assetId/decisionRecord a reviewer's decision on an asset, replacing the policy's.
Organise
PATCH /assets/:assetIdUpdate an existing asset
POST /assets/:assetId/moveMove an asset into a folder, or to the project root
Remove and batch
DELETE /assets/:assetId/contentRemove stored content, including the content derived from it in child assets, while retaining the asset records
DELETE /assets/:assetIdDelete an uploaded asset, its child assets and their stored content from a project.
POST /projects/:projectId/assets/batchDelete up to 500 assets, or remove their stored content, in one request.

Folders

EndpointDescription
GET /projects/:projectId/foldersList a page of child folders, or search them by name.
POST /projects/:projectId/foldersCreate an asset folder with an optional parent folder ID
GET /folders/:folderIdGet an asset folder by ID
PATCH /folders/:folderIdRename an asset folder
DELETE /folders/:folderIdDelete an empty asset folder by ID
POST /folders/:folderId/moveMove a folder under another folder, or to the project root.
POST /assets/:assetId/moveMove an asset into a folder, or to the project root

Hash lists

EndpointDescription
GET /projects/:projectId/hash-listsGet a page of a project's hash lists, newest first
POST /projects/:projectId/hash-listsCreate a hash list.
GET /hash-lists/:hashListIdGet a hash list by ID
PATCH /hash-lists/:hashListIdRename a hash list or change what its matches do.
DELETE /hash-lists/:hashListIdDelete a hash list and every entry in it.
GET /hash-lists/:hashListId/entriesGet a page of the hashes in a hash list, newest first
POST /hash-lists/:hashListId/entriesAdd a PDQ hash to a hash list, either as a hash or from an image asset.
DELETE /hash-list-entries/:entryIdRemove a hash from its hash list.

Policies

EndpointDescription
GET /policiesList a page of the moderation policies of the API key's organisation, oldest first.
POST /policiesCreate a moderation policy in the API key's organisation, from settings or as a copy of a built-in preset.
GET /policies/:policyIdGet one of the organisation's moderation policies by ID
PATCH /policies/:policyIdChange a policy's name, description or settings.
POST /policies/:policyId/resetRestore the settings of the preset release a pinned or copy policy is pinned to, discarding its edits
POST /policies/:policyId/upgradeMove a pinned or copy policy whose settings are unchanged from its preset release to the latest release of the preset
PUT /policies/:policyId/automatic-updatesSwitch automatic updates on or off for one of the organisation's own preset policies: on turns a pinned policy live, so it always has the latest preset settings, and off pins a live policy at its current preset release.
DELETE /policies/:policyIdDelete a policy that no project or upload preset uses.
GET /projects/:projectId/policyGet the policy the project moderates with.
PUT /projects/:projectId/policyChoose the policy the project moderates with.

Lenses

EndpointDescription
PUT /projects/:projectId/lensesCreate each lens, or change it to the definition sent, by identifier.
GET /projects/:projectId/lensesList a page of the project's lenses, newest first.
POST /projects/:projectId/lensesCreate a lens.
GET /lenses/:lensIdGet one of the project's lenses by ID
PATCH /lenses/:lensIdChange a lens's name, description, type, transform or whether the CDN serves it.
DELETE /lenses/:lensIdDelete a lens.

CDN

EndpointDescription
POST /projects/:projectId/signed-asset-urlsCreate a short-lived signed URL for a private asset, the base URL of all its CDN resources

Events

EndpointDescription
GET /projects/:projectId/eventsList project events, oldest first, after a cursor.

Health check

EndpointDescription
GET /health-checkCheck whether the public API worker is responding

Last updated

Signing in

Signing out

Cookies on CalmLens

We use essential cookies for sign-in and security. With your permission, functional cookies remember your preferences and Google Analytics measures website use and signups. Optional ad measurement cookies link Google ad clicks to signups. Personalised advertising stays off. Manage cookies