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
| Service | Base URL |
|---|---|
| REST API | https://api.calmlens.com/v1 |
| CDN | https://cdn.calmlens.com/v1 |
| MCP server | https://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-keyThe 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_8fK2mQx7Lp4NvB3tRz9Yfor a project,asset_5Gm2Rk8XqT3wLp9VbN4cfor an asset andevt_7Lm3Xq8Rk2Vt9Wb4Np5Cfor 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 ownexternalId, which the CDN accepts in place of the asset ID. - Pagination. Every list takes an optional
cursorand apageSizefrom 1 to 100 (default 50), and returnsitems,nextCursorandhasMore. PassnextCursoras the next request’scursoruntilhasMoreisfalse. Lists that can be sorted takesort, a comma-separated list of fields, each descending when prefixed with-, such as-createdAt,id. The events feed always returns anextCursorto 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,requestIdanddetails. Handle errors bycode; each endpoint card lists the codes it can return. See Error handling. - Request IDs. Every response carries an
X-Request-Idheader, and error bodies repeat it asrequestId. Include it when you contact support about a request. - Idempotency. Asset uploads and upload parts accept an
Idempotency-Keyheader, 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
429with aRetry-Afterheader. 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
| Endpoint | Description |
|---|---|
| Upload | |
POST / | Upload a new asset to a project. |
POST / | Upload 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 / | Start 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 / | Upload a sequential part for an in-progress asset upload. |
| Browser uploads | |
POST / | Upload a file from a browser or app through an upload preset, without an API key. |
POST / | Upload 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 the next part of a multipart upload started through an upload preset. |
GET / | Check an upload made through an upload preset. |
| Read and review | |
GET / | List a page of the project's assets, optionally in one folder or matching a filter |
GET / | Search accessible assets by keyword or natural language. |
GET / | Get a single asset by ID |
GET / | Get child assets of a parent asset |
GET / | Page through every segment of an audio or video asset's findings timeline, in time order. |
POST / | Process an asset whose classification.status is failed again. |
POST / | Complete the policy evidence behind an asset's moderation decision. |
POST / | Record a reviewer's decision on an asset, replacing the policy's. |
| Organise | |
PATCH / | Update an existing asset |
POST / | Move an asset into a folder, or to the project root |
| Remove and batch | |
DELETE / | Remove stored content, including the content derived from it in child assets, while retaining the asset records |
DELETE / | Delete an uploaded asset, its child assets and their stored content from a project. |
POST / | Delete up to 500 assets, or remove their stored content, in one request. |
Folders
| Endpoint | Description |
|---|---|
GET / | List a page of child folders, or search them by name. |
POST / | Create an asset folder with an optional parent folder ID |
GET / | Get an asset folder by ID |
PATCH / | Rename an asset folder |
DELETE / | Delete an empty asset folder by ID |
POST / | Move a folder under another folder, or to the project root. |
POST / | Move an asset into a folder, or to the project root |
Hash lists
| Endpoint | Description |
|---|---|
GET / | Get a page of a project's hash lists, newest first |
POST / | Create a hash list. |
GET / | Get a hash list by ID |
PATCH / | Rename a hash list or change what its matches do. |
DELETE / | Delete a hash list and every entry in it. |
GET / | Get a page of the hashes in a hash list, newest first |
POST / | Add a PDQ hash to a hash list, either as a hash or from an image asset. |
DELETE / | Remove a hash from its hash list. |
Policies
| Endpoint | Description |
|---|---|
GET / | List a page of the moderation policies of the API key's organisation, oldest first. |
POST / | Create a moderation policy in the API key's organisation, from settings or as a copy of a built-in preset. |
GET / | Get one of the organisation's moderation policies by ID |
PATCH / | Change a policy's name, description or settings. |
POST / | Restore the settings of the preset release a pinned or copy policy is pinned to, discarding its edits |
POST / | Move a pinned or copy policy whose settings are unchanged from its preset release to the latest release of the preset |
PUT / | Switch 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 / | Delete a policy that no project or upload preset uses. |
GET / | Get the policy the project moderates with. |
PUT / | Choose the policy the project moderates with. |
Lenses
| Endpoint | Description |
|---|---|
PUT / | Create each lens, or change it to the definition sent, by identifier. |
GET / | List a page of the project's lenses, newest first. |
POST / | Create a lens. |
GET / | Get one of the project's lenses by ID |
PATCH / | Change a lens's name, description, type, transform or whether the CDN serves it. |
DELETE / | Delete a lens. |
CDN
| Endpoint | Description |
|---|---|
POST / | Create a short-lived signed URL for a private asset, the base URL of all its CDN resources |
Events
| Endpoint | Description |
|---|---|
GET / | List project events, oldest first, after a cursor. |
Health check
| Endpoint | Description |
|---|---|
GET / | Check whether the public API worker is responding |