Assets API reference

An asset is one piece of submitted content (text, a file or a URL) together with its classification results. Use these endpoints to upload, list, update, move, retry and delete assets.

Guides: Classify assets, Asset lifecycle, Delivering assets.

Wait for moderation or queue it

For uploads, wait=true (the HTTP default) waits for classification and returns the decision. Set wait=false to return an asset ID while moderation runs, then receive an asset.allowed, asset.limited, asset.age-restricted, asset.blocked or asset.purged event through a webhook. Also handle asset.failed for processing failures.

client.assets.classify() selects wait=true, and client.assets.create() selects wait=false. Text, images, documents and websites support both flows. Audio and video always run asynchronously and return with classification.moderation.status pending, even with wait=true. See Waiting for the decision for the complete flow.

Endpoints

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.

Endpoint details

Create Asset

Upload a new asset to a project. Images up to 10 MiB, audio and video up to 50 MiB and 120 seconds, and other files up to 5,000 MiB can be sent in one request. Images up to 20 MiB, and any file within its limit, can also be sent in sequential parts with a multipart upload, which can resume after a failed part; CalmLens accumulates parts and enforces the final total, and checks `totalSizeInBytes` up front when you send it. Retained multipart image originals are served through CalmLens CDN URLs. Send an `Idempotency-Key` header to retry safely without creating a second asset.

OpenAPI YAML
POST
https://api.calmlens.com/v1/projects/
/assets
const response = await client.assets.create({
  "name": "homepage-image.jpg",
  "url": "https://example.com/image.jpg",
  "visibility": "private",
  "processingOptions": {
    "keepContentAfterProcessing": true
  }
});

Query Parameters

Edit any value to update the generated request examples.

boolean
Whether to wait for the decision before responding (the default), or to respond straight away with the asset queued and decide it in the background. Audio, video and files over 20 MiB sent in parts are always decided in the background, whatever wait says. A multipart upload saves this choice and applies it when the final part arrives.

Request Body

Edit any value to update the generated request examples.

string (optional)
Optional description of the asset
Visibility (optional)
Visibility level of the asset
Allowed values
publicprivate
tags[]string[]
Array of tags for the asset
string (optional)
External identifier for the asset
string (optional)
External URL associated with the asset (http or https)
string (optional)
string (optional)
Your identifier for who wrote the content, up to 256 characters. CalmLens only compares it with the author IDs in context, to tell which posts share a speaker, so any stable opaque value works. See Threaded moderation.
string (optional)

Response


Error Codes

401api-key/missing
Authentication required. Send your project API key in the X-Api-Key header.
401api-key/invalid
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403api-key/project-mismatch
This API key belongs to a different project. Use a key created for the project that owns this resource.
403auth/permission-denied
This API key lacks a permission the request needs (details.permission names it, such as assets:download for an asset's folder), or the resource belongs to another project.
400validation/invalid-request
The request's parameters, query or body are invalid. details.issues lists each problem, with its path and issue code.
415request/unsupported-content-type
Send the request body as application/json.
413upload/too-large
The file is larger than allowed. details.limitBytes is the limit, and details.source says whether it is the plan's (`plan`) or the upload preset's (`preset`).
422image/invalid
The image is corrupt or cannot be decoded. Upload a valid image file.
415upload/unsupported-type
The file type is not accepted. details.source is `calmlens` when CalmLens cannot store and process it (use a concrete MIME type such as image/png, application/pdf or text/plain) or `preset` when the upload preset doesn't allow it.
422image/too-large
The image exceeds a processing limit: details.limit is `bytes`, `pixels` or `dimension`. Reduce its size before uploading.
422document/too-many-items
The document holds more embedded images or audio and video files than can be moderated: details.limit is `images` or `media` and details.maximum the most allowed. Split it into smaller documents.
403usage/free-uploads-exhausted
This project's organisation has used its free uploads. Set up billing to continue uploading.
402usage/uploads-paused
Uploads to this project are paused by its organisation's usage limits. See details.reason; an owner can review them in Billing.
400remote-url/invalid
Remote URLs must use HTTP or HTTPS and cannot target private networks, localhost names or URL credentials.
422remote-url/unavailable
The URL responded with an error status. Check that it is publicly reachable.
400remote-url/too-many-redirects
The remote URL redirected too many times.
403remote-url/not-allowed
This project doesn't accept URLs from this domain. Change the allowed or blocked domains under Project settings.
429upload/website-rate-limit-reached
This project has submitted too many websites in the last minute. Wait for the Retry-After period, or lower the pace of submissions.
409asset/duplicate-external-id
An asset with this externalId already exists in the project.
404folder/not-found
Folder not found
400upload-payload/invalid
Upload payload is invalid.
409upload/use-upload-part
Use uploadPart for multipart upload parts after the first part
404upload-preset/not-found
Upload preset not found. Check the preset ID in the portal.
403upload-preset/disabled
This upload preset is paused. Turn it on in the portal to accept uploads.
400upload-preset/field-not-allowed
This field is set by the upload preset or the upload token and can't be changed by the upload.
400idempotency/invalid-key
The Idempotency-Key header must be 1 to 255 printable ASCII characters, such as a UUID.
409idempotency/key-reused
This Idempotency-Key was already used for a different request. Use a new key for each distinct request.
409idempotency/request-in-progress
A request with this Idempotency-Key is still being processed. Retry after the Retry-After delay to receive its result.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Upload Asset File

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`. Asset fields are query parameters. This is the upload path the SDKs use for files. Send an `Idempotency-Key` header to retry safely without creating a second asset.

OpenAPI YAML
POST
https://api.calmlens.com/v1/projects/
/assets
import { readFile } from "node:fs/promises";
const response = await client.assets.create({
  "name": "cat.jpg",
  "visibility": "private",
  "content": {
    "buffer": await readFile("cat.jpg"),
    "type": "image/jpeg"
  }
});

Query Parameters

Edit any value to update the generated request examples.

string
Name of the asset
string
MIME type of the file, such as image/jpeg. Ambiguous types are rejected.
boolean
Whether to wait for the decision before responding (the default), or to respond straight away with the asset queued and decide it in the background. Audio, video and files over 20 MiB sent in parts are always decided in the background, whatever wait says. A multipart upload saves this choice and applies it when the final part arrives.
boolean
Multipart uploads only: true when this is the last part
string (optional)
Optional description of the asset
string (optional)
Processing options, such as {"keepContentAfterProcessing":true}
Visibility (optional)
Visibility of the asset
Allowed values
publicprivate
string (optional)
Custom metadata as a URL-encoded JSON array of { id, value } items
string (optional)
Tags as a URL-encoded JSON array of strings, such as ["catalogue","backpacks"]
string (optional)
Your identifier for the asset
string (optional)
URL in your app associated with the asset (http or https)
string (optional)
ID of the folder to upload into
string (optional)
Your identifier for who wrote the content, up to 256 characters. CalmLens only compares it with the author IDs in context, to tell which posts share a speaker, so any stable opaque value works. See Threaded moderation.
string (optional)
Earlier posts in the conversation as URL-encoded JSON, such as {"items":[{"text":"Anyone tried the update?","authorId":"user-456"}]}. The SDKs send only the posts CalmLens uses. See Threaded moderation.
string (optional)
ID of an upload preset to apply. Its folder, visibility, file types and size limit apply to the upload.
number (optional)
Multipart uploads only: the part number, starting at 1
number (optional)
The exact size of this request's body in bytes. For a multipart upload, the size of the first part.
number (optional)
Multipart uploads only: the size of the whole file in bytes, if known. CalmLens checks it against the upload limits before any part is stored, and the final part fails with upload/size-mismatch if the parts add up to a different size.

Response


Error Codes

401api-key/missing
Authentication required. Send your project API key in the X-Api-Key header.
401api-key/invalid
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403api-key/project-mismatch
This API key belongs to a different project. Use a key created for the project that owns this resource.
403auth/permission-denied
This API key lacks a permission the request needs (details.permission names it, such as assets:download for an asset's folder), or the resource belongs to another project.
400validation/invalid-request
The request's parameters, query or body are invalid. details.issues lists each problem, with its path and issue code.
413upload/too-large
The file is larger than allowed. details.limitBytes is the limit, and details.source says whether it is the plan's (`plan`) or the upload preset's (`preset`).
422image/invalid
The image is corrupt or cannot be decoded. Upload a valid image file.
415upload/unsupported-type
The file type is not accepted. details.source is `calmlens` when CalmLens cannot store and process it (use a concrete MIME type such as image/png, application/pdf or text/plain) or `preset` when the upload preset doesn't allow it.
422image/too-large
The image exceeds a processing limit: details.limit is `bytes`, `pixels` or `dimension`. Reduce its size before uploading.
422document/too-many-items
The document holds more embedded images or audio and video files than can be moderated: details.limit is `images` or `media` and details.maximum the most allowed. Split it into smaller documents.
403usage/free-uploads-exhausted
This project's organisation has used its free uploads. Set up billing to continue uploading.
402usage/uploads-paused
Uploads to this project are paused by its organisation's usage limits. See details.reason; an owner can review them in Billing.
409asset/duplicate-external-id
An asset with this externalId already exists in the project.
404folder/not-found
Folder not found
400upload-payload/invalid
Upload payload is invalid.
404upload-preset/not-found
Upload preset not found. Check the preset ID in the portal.
403upload-preset/disabled
This upload preset is paused. Turn it on in the portal to accept uploads.
400upload-preset/field-not-allowed
This field is set by the upload preset or the upload token and can't be changed by the upload.
400idempotency/invalid-key
The Idempotency-Key header must be 1 to 255 printable ASCII characters, such as a UUID.
409idempotency/key-reused
This Idempotency-Key was already used for a different request. Use a new key for each distinct request.
409idempotency/request-in-progress
A request with this Idempotency-Key is still being processed. Retry after the Retry-After delay to receive its result.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Start Multipart File Upload

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`. Pass `partNumber=1`, `isFinal`, the part's `sizeInBytes` and, if known, the file's `totalSizeInBytes` as query parameters, then send later parts to Upload Asset Part. The `wait` choice is saved with the upload and applies when the final part arrives.

OpenAPI YAML
POST
https://api.calmlens.com/v1/projects/
/assets
import { readFile } from "node:fs/promises";

const response = await fetch("https://api.calmlens.com/v1/projects/proj_8fK2mQx7Lp4NvB3tRz9Y/assets?name=large-video.mp4&contentType=video%2Fmp4&partNumber=1&isFinal=false", {
  method: "POST",
  headers: {
    "X-Api-Key": "your-api-key",
    "X-CalmLens-Upload": "part",
    "Content-Type": "video/mp4",
  },
  body: await readFile("large-video.part1"),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();

Query Parameters

Edit any value to update the generated request examples.

string
Name of the asset
string
MIME type of the file, such as image/jpeg. Ambiguous types are rejected.
boolean
Whether to wait for the decision before responding (the default), or to respond straight away with the asset queued and decide it in the background. Audio, video and files over 20 MiB sent in parts are always decided in the background, whatever wait says. A multipart upload saves this choice and applies it when the final part arrives.
boolean
Multipart uploads only: true when this is the last part
string (optional)
Optional description of the asset
string (optional)
Processing options, such as {"keepContentAfterProcessing":true}
Visibility (optional)
Visibility of the asset
Allowed values
publicprivate
string (optional)
Custom metadata as a URL-encoded JSON array of { id, value } items
string (optional)
Tags as a URL-encoded JSON array of strings, such as ["catalogue","backpacks"]
string (optional)
Your identifier for the asset
string (optional)
URL in your app associated with the asset (http or https)
string (optional)
ID of the folder to upload into
string (optional)
Your identifier for who wrote the content, up to 256 characters. CalmLens only compares it with the author IDs in context, to tell which posts share a speaker, so any stable opaque value works. See Threaded moderation.
string (optional)
Earlier posts in the conversation as URL-encoded JSON, such as {"items":[{"text":"Anyone tried the update?","authorId":"user-456"}]}. The SDKs send only the posts CalmLens uses. See Threaded moderation.
string (optional)
ID of an upload preset to apply. Its folder, visibility, file types and size limit apply to the upload.
number (optional)
Multipart uploads only: the part number, starting at 1
number (optional)
The exact size of this request's body in bytes. For a multipart upload, the size of the first part.
number (optional)
Multipart uploads only: the size of the whole file in bytes, if known. CalmLens checks it against the upload limits before any part is stored, and the final part fails with upload/size-mismatch if the parts add up to a different size.

Response


Error Codes

401api-key/missing
Authentication required. Send your project API key in the X-Api-Key header.
401api-key/invalid
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403api-key/project-mismatch
This API key belongs to a different project. Use a key created for the project that owns this resource.
403auth/permission-denied
This API key lacks a permission the request needs (details.permission names it, such as assets:download for an asset's folder), or the resource belongs to another project.
400validation/invalid-request
The request's parameters, query or body are invalid. details.issues lists each problem, with its path and issue code.
413upload/too-large
The file is larger than allowed. details.limitBytes is the limit, and details.source says whether it is the plan's (`plan`) or the upload preset's (`preset`).
422image/invalid
The image is corrupt or cannot be decoded. Upload a valid image file.
415upload/unsupported-type
The file type is not accepted. details.source is `calmlens` when CalmLens cannot store and process it (use a concrete MIME type such as image/png, application/pdf or text/plain) or `preset` when the upload preset doesn't allow it.
422image/too-large
The image exceeds a processing limit: details.limit is `bytes`, `pixels` or `dimension`. Reduce its size before uploading.
422document/too-many-items
The document holds more embedded images or audio and video files than can be moderated: details.limit is `images` or `media` and details.maximum the most allowed. Split it into smaller documents.
403usage/free-uploads-exhausted
This project's organisation has used its free uploads. Set up billing to continue uploading.
402usage/uploads-paused
Uploads to this project are paused by its organisation's usage limits. See details.reason; an owner can review them in Billing.
409asset/duplicate-external-id
An asset with this externalId already exists in the project.
404folder/not-found
Folder not found
400upload-payload/invalid
Upload payload is invalid.
404upload-preset/not-found
Upload preset not found. Check the preset ID in the portal.
403upload-preset/disabled
This upload preset is paused. Turn it on in the portal to accept uploads.
400upload-preset/field-not-allowed
This field is set by the upload preset or the upload token and can't be changed by the upload.
400idempotency/invalid-key
The Idempotency-Key header must be 1 to 255 printable ASCII characters, such as a UUID.
409idempotency/key-reused
This Idempotency-Key was already used for a different request. Use a new key for each distinct request.
409idempotency/request-in-progress
A request with this Idempotency-Key is still being processed. Retry after the Retry-After delay to receive its result.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Upload Asset Part

Upload a sequential part for an in-progress asset upload. Each non-final part must be at least 5 MiB, an upload has at most 10,000 parts, and image uploads in parts must total at most 20 MiB. The final part uses the `wait` choice saved when the upload started unless you pass `wait` here. To stream raw bytes instead of JSON, send the `X-CalmLens-Upload: part` header and pass `partNumber`, `isFinal` and `sizeInBytes` as query parameters.

OpenAPI YAML
POST
https://api.calmlens.com/v1/assets/
/part
const response = await client.assets.uploadPart({
  "assetId": "asset_5Gm2Rk8XqT3wLp9VbN4c",
  "part": {
    "base64": "<base64-encoded-part>",
    "partNumber": 2,
    "isFinal": false
  }
});

Query Parameters

Edit any value to update the generated request examples.

boolean (optional)
Overrides whether the final part waits for the decision (true) or responds straight away with the asset queued (false). When omitted, the upload uses the wait value sent when it started. Audio and video are always decided in the background.

Request Body

Edit any value to update the generated request examples.

partunion

Response


Error Codes

401api-key/missing
Authentication required. Send your project API key in the X-Api-Key header.
401api-key/invalid
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403api-key/project-mismatch
This API key belongs to a different project. Use a key created for the project that owns this resource.
403auth/permission-denied
This API key lacks a permission the request needs (details.permission names it, such as assets:download for an asset's folder), or the resource belongs to another project.
400validation/invalid-request
The request's parameters, query or body are invalid. details.issues lists each problem, with its path and issue code.
415request/unsupported-content-type
Send the request body as application/json.
404asset/not-found
Asset not found
413upload/too-large
The file is larger than allowed. details.limitBytes is the limit, and details.source says whether it is the plan's (`plan`) or the upload preset's (`preset`).
422image/invalid
The image is corrupt or cannot be decoded. Upload a valid image file.
415upload/unsupported-type
The file type is not accepted. details.source is `calmlens` when CalmLens cannot store and process it (use a concrete MIME type such as image/png, application/pdf or text/plain) or `preset` when the upload preset doesn't allow it.
422image/too-large
The image exceeds a processing limit: details.limit is `bytes`, `pixels` or `dimension`. Reduce its size before uploading.
400upload-payload/invalid
Upload payload is invalid.
409upload/not-open
Asset is not accepting additional parts
409upload-part/invalid-number
Multipart upload part number is invalid.
409upload/missing
Multipart upload state is missing
400upload/size-mismatch
The uploaded parts do not add up to the totalSizeInBytes declared when the multipart upload started.
400idempotency/invalid-key
The Idempotency-Key header must be 1 to 255 printable ASCII characters, such as a UUID.
409idempotency/key-reused
This Idempotency-Key was already used for a different request. Use a new key for each distinct request.
409idempotency/request-in-progress
A request with this Idempotency-Key is still being processed. Retry after the Retry-After delay to receive its result.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Create Preset Upload

Upload a file from a browser or app through an upload preset, without an API key. The preset sets the folder, visibility, accepted file types and size limit. To start a multipart upload, send the first `part` instead of `content`. Send the upload token signed by your server as `Authorization: Bearer <token>`; presets open to anyone need no token. Browsers must send an `Origin` the preset allows. The response includes the decision only when the preset shows it to uploaders.

OpenAPI YAML
POST
https://api.calmlens.com/v1/upload-presets/
/assets
const response = await fetch("https://api.calmlens.com/v1/upload-presets/preset_4Lk8Qw2Xm9Rt5Vb3Nc7P/assets?wait=false", {
  method: "POST",
  headers: {
    "Authorization": "Bearer your-upload-token",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
  "name": "comment.txt",
  "content": {
    "plainText": "Great photo!",
    "type": "text/plain"
  }
})
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);

const data = await response.json();

Query Parameters

Edit any value to update the generated request examples.

boolean
Whether to wait for the decision before responding (the default), or to respond straight away with the asset queued and decide it in the background. Audio, video and files over 20 MiB sent in parts are always decided in the background, whatever wait says. A multipart upload saves this choice and applies it when the final part arrives.

Request Body

Edit any value to update the generated request examples.

string
Name of the asset
string (optional)
Optional description of the asset

Response


Error Codes

400validation/invalid-request
The request's parameters, query or body are invalid. details.issues lists each problem, with its path and issue code.
415request/unsupported-content-type
Send the request body as application/json.
404upload-preset/not-found
Upload preset not found. Check the preset ID in the portal.
403upload-preset/disabled
This upload preset is paused. Turn it on in the portal to accept uploads.
403upload-preset/origin-not-allowed
This site isn't allowed to upload through this upload preset.
401upload-preset/token-required
This upload preset only accepts uploads with an upload token. Sign one on your server with uploadTokens.sign and pass it to the client.
401upload-token/invalid
The upload token is invalid. Sign a new one on your server with an active API key for this project.
401upload-token/expired
The upload token has expired. Sign a new one on your server.
429upload-preset/daily-limit-reached
You have reached this upload preset's daily upload limit. Try again after midnight UTC.
415upload/unsupported-type
The file type is not accepted. details.source is `calmlens` when CalmLens cannot store and process it (use a concrete MIME type such as image/png, application/pdf or text/plain) or `preset` when the upload preset doesn't allow it.
413upload/too-large
The file is larger than allowed. details.limitBytes is the limit, and details.source says whether it is the plan's (`plan`) or the upload preset's (`preset`).
400upload-preset/field-not-allowed
This field is set by the upload preset or the upload token and can't be changed by the upload.
409upload-token/used
The upload token has already been used. Each token uploads one asset.
422image/invalid
The image is corrupt or cannot be decoded. Upload a valid image file.
422image/too-large
The image exceeds a processing limit: details.limit is `bytes`, `pixels` or `dimension`. Reduce its size before uploading.
403usage/free-uploads-exhausted
This project's organisation has used its free uploads. Set up billing to continue uploading.
402usage/uploads-paused
Uploads to this project are paused by its organisation's usage limits. See details.reason; an owner can review them in Billing.
400upload-payload/invalid
Upload payload is invalid.
400idempotency/invalid-key
The Idempotency-Key header must be 1 to 255 printable ASCII characters, such as a UUID.
409idempotency/key-reused
This Idempotency-Key was already used for a different request. Use a new key for each distinct request.
409idempotency/request-in-progress
A request with this Idempotency-Key is still being processed. Retry after the Retry-After delay to receive its result.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Upload Preset File

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`. To start a multipart upload, send `X-CalmLens-Upload: part` with `partNumber=1`, `isFinal` and `sizeInBytes`. Send the upload token signed by your server as `Authorization: Bearer <token>`; presets open to anyone need no token. Browsers must send an `Origin` the preset allows.

OpenAPI YAML
POST
https://api.calmlens.com/v1/upload-presets/
/assets
import { readFile } from "node:fs/promises";

const response = await fetch("https://api.calmlens.com/v1/upload-presets/preset_4Lk8Qw2Xm9Rt5Vb3Nc7P/assets?name=photo.jpg&contentType=image%2Fjpeg&wait=false", {
  method: "POST",
  headers: {
    "Authorization": "Bearer your-upload-token",
    "X-CalmLens-Upload": "content",
    "Content-Type": "image/jpeg",
  },
  body: await readFile("photo.jpg"),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();

Query Parameters

Edit any value to update the generated request examples.

string
Name of the asset
string
MIME type of the file, such as image/jpeg. Ambiguous types are rejected.
boolean
Whether to wait for the decision before responding (the default), or to respond straight away with the asset queued and decide it in the background. Audio, video and files over 20 MiB sent in parts are always decided in the background, whatever wait says. A multipart upload saves this choice and applies it when the final part arrives.
boolean
Multipart uploads only: true when this is the last part
string (optional)
Optional description of the asset
number (optional)
Multipart uploads only: the part number, starting at 1
number (optional)
The exact size of this request's body in bytes. For a multipart upload, the size of the first part.
number (optional)
Multipart uploads only: the size of the whole file in bytes, if known. CalmLens checks it against the upload limits before any part is stored, and the final part fails with upload/size-mismatch if the parts add up to a different size.

Response


Error Codes

400validation/invalid-request
The request's parameters, query or body are invalid. details.issues lists each problem, with its path and issue code.
404upload-preset/not-found
Upload preset not found. Check the preset ID in the portal.
403upload-preset/disabled
This upload preset is paused. Turn it on in the portal to accept uploads.
403upload-preset/origin-not-allowed
This site isn't allowed to upload through this upload preset.
401upload-preset/token-required
This upload preset only accepts uploads with an upload token. Sign one on your server with uploadTokens.sign and pass it to the client.
401upload-token/invalid
The upload token is invalid. Sign a new one on your server with an active API key for this project.
401upload-token/expired
The upload token has expired. Sign a new one on your server.
429upload-preset/daily-limit-reached
You have reached this upload preset's daily upload limit. Try again after midnight UTC.
415upload/unsupported-type
The file type is not accepted. details.source is `calmlens` when CalmLens cannot store and process it (use a concrete MIME type such as image/png, application/pdf or text/plain) or `preset` when the upload preset doesn't allow it.
413upload/too-large
The file is larger than allowed. details.limitBytes is the limit, and details.source says whether it is the plan's (`plan`) or the upload preset's (`preset`).
400upload-preset/field-not-allowed
This field is set by the upload preset or the upload token and can't be changed by the upload.
409upload-token/used
The upload token has already been used. Each token uploads one asset.
422image/invalid
The image is corrupt or cannot be decoded. Upload a valid image file.
422image/too-large
The image exceeds a processing limit: details.limit is `bytes`, `pixels` or `dimension`. Reduce its size before uploading.
403usage/free-uploads-exhausted
This project's organisation has used its free uploads. Set up billing to continue uploading.
402usage/uploads-paused
Uploads to this project are paused by its organisation's usage limits. See details.reason; an owner can review them in Billing.
400upload-payload/invalid
Upload payload is invalid.
400idempotency/invalid-key
The Idempotency-Key header must be 1 to 255 printable ASCII characters, such as a UUID.
409idempotency/key-reused
This Idempotency-Key was already used for a different request. Use a new key for each distinct request.
409idempotency/request-in-progress
A request with this Idempotency-Key is still being processed. Retry after the Retry-After delay to receive its result.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Upload Preset Part

Upload the next part of a multipart upload started through an upload preset. It takes the same body and query as Upload Asset Part, including raw bytes with `X-CalmLens-Upload: part`. The upload token that started the upload keeps working for its parts for up to a day after it expires. Send the upload token signed by your server as `Authorization: Bearer <token>`; presets open to anyone need no token. Browsers must send an `Origin` the preset allows.

OpenAPI YAML
POST
https://api.calmlens.com/v1/upload-presets/
/assets/
/part
const response = await fetch("https://api.calmlens.com/v1/upload-presets/preset_4Lk8Qw2Xm9Rt5Vb3Nc7P/assets/asset_5Gm2Rk8XqT3wLp9VbN4c/part", {
  method: "POST",
  headers: {
    "Authorization": "Bearer your-upload-token",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
  "part": {
    "base64": "<base64-encoded-part>",
    "partNumber": 2,
    "isFinal": true
  }
})
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);

const data = await response.json();

Query Parameters

Edit any value to update the generated request examples.

boolean (optional)
Overrides whether the final part waits for the decision (true) or responds straight away with the asset queued (false). When omitted, the upload uses the wait value sent when it started. Audio and video are always decided in the background.

Request Body

Edit any value to update the generated request examples.

partunion

Response


Error Codes

400validation/invalid-request
The request's parameters, query or body are invalid. details.issues lists each problem, with its path and issue code.
415request/unsupported-content-type
Send the request body as application/json.
404upload-preset/not-found
Upload preset not found. Check the preset ID in the portal.
403upload-preset/disabled
This upload preset is paused. Turn it on in the portal to accept uploads.
403upload-preset/origin-not-allowed
This site isn't allowed to upload through this upload preset.
401upload-preset/token-required
This upload preset only accepts uploads with an upload token. Sign one on your server with uploadTokens.sign and pass it to the client.
401upload-token/invalid
The upload token is invalid. Sign a new one on your server with an active API key for this project.
401upload-token/expired
The upload token has expired. Sign a new one on your server.
413upload/too-large
The file is larger than allowed. details.limitBytes is the limit, and details.source says whether it is the plan's (`plan`) or the upload preset's (`preset`).
404asset/not-found
Asset not found
422image/invalid
The image is corrupt or cannot be decoded. Upload a valid image file.
415upload/unsupported-type
The file type is not accepted. details.source is `calmlens` when CalmLens cannot store and process it (use a concrete MIME type such as image/png, application/pdf or text/plain) or `preset` when the upload preset doesn't allow it.
422image/too-large
The image exceeds a processing limit: details.limit is `bytes`, `pixels` or `dimension`. Reduce its size before uploading.
400upload-payload/invalid
Upload payload is invalid.
409upload/not-open
Asset is not accepting additional parts
409upload-part/invalid-number
Multipart upload part number is invalid.
409upload/missing
Multipart upload state is missing
400upload/size-mismatch
The uploaded parts do not add up to the totalSizeInBytes declared when the multipart upload started.
400idempotency/invalid-key
The Idempotency-Key header must be 1 to 255 printable ASCII characters, such as a UUID.
409idempotency/key-reused
This Idempotency-Key was already used for a different request. Use a new key for each distinct request.
409idempotency/request-in-progress
A request with this Idempotency-Key is still being processed. Retry after the Retry-After delay to receive its result.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Retrieve Preset Upload

Check an upload made through an upload preset. Only assets uploaded through that preset are found, and the status is included only when the preset shows decisions to uploaders. Send the upload token signed by your server as `Authorization: Bearer <token>`; presets open to anyone need no token. Browsers must send an `Origin` the preset allows.

OpenAPI YAML
GET
https://api.calmlens.com/v1/upload-presets/
/assets/
const response = await fetch("https://api.calmlens.com/v1/upload-presets/preset_4Lk8Qw2Xm9Rt5Vb3Nc7P/assets/asset_5Gm2Rk8XqT3wLp9VbN4c", {
  method: "GET",
  headers: {
    "Authorization": "Bearer your-upload-token"
  }
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);

const data = await response.json();

Response


Error Codes

400validation/invalid-request
The request's parameters, query or body are invalid. details.issues lists each problem, with its path and issue code.
404upload-preset/not-found
Upload preset not found. Check the preset ID in the portal.
403upload-preset/disabled
This upload preset is paused. Turn it on in the portal to accept uploads.
403upload-preset/origin-not-allowed
This site isn't allowed to upload through this upload preset.
401upload-preset/token-required
This upload preset only accepts uploads with an upload token. Sign one on your server with uploadTokens.sign and pass it to the client.
401upload-token/invalid
The upload token is invalid. Sign a new one on your server with an active API key for this project.
401upload-token/expired
The upload token has expired. Sign a new one on your server.
404asset/not-found
Asset not found
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

List Assets

List a page of the project's assets, optionally in one folder or matching a filter

OpenAPI YAML
GET
https://api.calmlens.com/v1/projects/
/assets
const response = await client.assets.list({
  "pageSize": 20
});

Query Parameters

Edit any value to update the generated request examples.

string (optional)
The previous page’s nextCursor; omit for the first page
number (optional)
Items per page, 1 to 100 (default 50)
string (optional)
Sort order: a comma-separated list of fields from createdAt, id, each ascending unless prefixed with -. The default is -createdAt. An id tie-breaker in the first field's direction is added.
string (optional)

RSQL filter string for filtering results. Only the fields listed in Asset filters can be filtered; see that section for detailed syntax.

Examples:

  • classification.moderation.status==blocked;parentId==null (AND conditions)
  • classification.moderation.status==allowed,classification.moderation.status==pending (OR conditions)
  • content.sizeInBytes>100000;content.sizeInBytes<500000 (range filtering)
  • tags=in=(catalogue,homepage) (array membership)
  • externalId==order:* (* matches any run of characters)

Supported operators: ==, !=, >, >=, <, <=, =in=, =out=

Logical operators: ; (AND), , (OR)


Response


Error Codes

401api-key/missing
Authentication required. Send your project API key in the X-Api-Key header.
401api-key/invalid
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403api-key/project-mismatch
This API key belongs to a different project. Use a key created for the project that owns this resource.
403auth/permission-denied
This API key lacks a permission the request needs (details.permission names it, such as assets:download for an asset's folder), or the resource belongs to another project.
400validation/invalid-request
The request's parameters, query or body are invalid. details.issues lists each problem, with its path and issue code.
400cursor/invalid
The cursor is invalid or belongs to a different query.
400filter/invalid
The filter has invalid syntax or names a field that can't be filtered.
404project/not-found
Project not found
404folder/not-found
Folder not found
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Search assets

Search accessible assets by keyword or natural language. Images are indexed automatically; enable audio and video search in project settings to include those media types. Results are the best `pageSize` matches (at most 20), ranked by relevance, so this endpoint has no cursor: refine the query, or list assets with a filter, to see more.

OpenAPI YAML
GET
https://api.calmlens.com/v1/projects/
/assets/search
const response = await client.assets.search({
  "query": "a red car at night",
  "mode": "hybrid",
  "pageSize": 10
});

Query Parameters

Edit any value to update the generated request examples.

string
number
How many of the best matches to return, 1 to 20
ModeEnum
Allowed values
keywordsemantichybrid

Response

querystring
semanticStatusSemanticStatusEnum
Allowed values
disabledreadyindexingunavailable

Error Codes

401api-key/missing
Authentication required. Send your project API key in the X-Api-Key header.
401api-key/invalid
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403api-key/project-mismatch
This API key belongs to a different project. Use a key created for the project that owns this resource.
403auth/permission-denied
This API key lacks a permission the request needs (details.permission names it, such as assets:download for an asset's folder), or the resource belongs to another project.
400validation/invalid-request
The request's parameters, query or body are invalid. details.issues lists each problem, with its path and issue code.
404project/not-found
Project not found
503search/unavailable
Search is temporarily unavailable. Retry later.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Get Asset

Get a single asset by ID

OpenAPI YAML
GET
https://api.calmlens.com/v1/assets/
const response = await client.assets.retrieve({
  "assetId": "asset_5Gm2Rk8XqT3wLp9VbN4c"
});

Response


Error Codes

401api-key/missing
Authentication required. Send your project API key in the X-Api-Key header.
401api-key/invalid
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403api-key/project-mismatch
This API key belongs to a different project. Use a key created for the project that owns this resource.
403auth/permission-denied
This API key lacks a permission the request needs (details.permission names it, such as assets:download for an asset's folder), or the resource belongs to another project.
400validation/invalid-request
The request's parameters, query or body are invalid. details.issues lists each problem, with its path and issue code.
404asset/not-found
Asset not found
404project/not-found
Project not found
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Get Asset Children

Get child assets of a parent asset

OpenAPI YAML
GET
https://api.calmlens.com/v1/assets/
/children
const response = await client.assets.listChildren({
  "pageSize": 20,
  "assetId": "asset_5Gm2Rk8XqT3wLp9VbN4c"
});

Query Parameters

Edit any value to update the generated request examples.

string (optional)
The previous page’s nextCursor; omit for the first page
number (optional)
Items per page, 1 to 100 (default 50)
string (optional)
Sort order: a comma-separated list of fields from createdAt, id, each ascending unless prefixed with -. The default is -createdAt. An id tie-breaker in the first field's direction is added.

Response


Error Codes

401api-key/missing
Authentication required. Send your project API key in the X-Api-Key header.
401api-key/invalid
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403api-key/project-mismatch
This API key belongs to a different project. Use a key created for the project that owns this resource.
403auth/permission-denied
This API key lacks a permission the request needs (details.permission names it, such as assets:download for an asset's folder), or the resource belongs to another project.
400validation/invalid-request
The request's parameters, query or body are invalid. details.issues lists each problem, with its path and issue code.
400cursor/invalid
The cursor is invalid or belongs to a different query.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Get Asset Timeline

Page through every segment of an audio or video asset's findings timeline, in time order. The asset's `classification.moderation.timeline.segmentCount` says how many there are. Lists nothing for other assets or while a copyright hold is on, and returns `asset/held` while a safety hold is on

OpenAPI YAML
GET
https://api.calmlens.com/v1/projects/
/assets/
/timeline
const response = await client.assets.listTimeline({
  "pageSize": 50,
  "assetId": "asset_5Gm2Rk8XqT3wLp9VbN4c"
});

Query Parameters

Edit any value to update the generated request examples.

string (optional)
The previous page’s nextCursor; omit for the first page
number (optional)
Items per page, 1 to 100 (default 50)

Response


Error Codes

401api-key/missing
Authentication required. Send your project API key in the X-Api-Key header.
401api-key/invalid
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403api-key/project-mismatch
This API key belongs to a different project. Use a key created for the project that owns this resource.
403auth/permission-denied
This API key lacks a permission the request needs (details.permission names it, such as assets:download for an asset's folder), or the resource belongs to another project.
400validation/invalid-request
The request's parameters, query or body are invalid. details.issues lists each problem, with its path and issue code.
404asset/not-found
Asset not found
423asset/held
The asset is held and this request can't change or deliver it. details.hold is `safety` for a safety hold or `copyright` for a copyright claim.
400cursor/invalid
The cursor is invalid or belongs to a different query.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Retry Asset

Process an asset whose `classification.status` is `failed` again. It returns to `processing` and is moderated like a new upload. The moderation decision must still be pending and the asset must not be under a safety hold. Processing needs available file content, inline text, or an eligible website URL to load again.

OpenAPI YAML
POST
https://api.calmlens.com/v1/assets/
/retry
const response = await client.assets.retry({
  "assetId": "asset_5Gm2Rk8XqT3wLp9VbN4c"
});

Response


Error Codes

401api-key/missing
Authentication required. Send your project API key in the X-Api-Key header.
401api-key/invalid
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403api-key/project-mismatch
This API key belongs to a different project. Use a key created for the project that owns this resource.
403auth/permission-denied
This API key lacks a permission the request needs (details.permission names it, such as assets:download for an asset's folder), or the resource belongs to another project.
400validation/invalid-request
The request's parameters, query or body are invalid. details.issues lists each problem, with its path and issue code.
404asset/not-found
Asset not found
409asset/not-retryable
Only assets that failed to process (status error) can be retried.
409asset/content-unavailable
This asset's content is no longer stored, so it can't be processed again. Upload it again instead.
423asset/held
The asset is held and this request can't change or deliver it. details.hold is `safety` for a safety hold or `copyright` for a copyright claim.
409asset/review-changed
The asset changed during review. Refresh and review the current decision.
429upload/website-rate-limit-reached
This project has submitted too many websites in the last minute. Wait for the Retry-After period, or lower the pace of submissions.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Explain Asset Decision

Complete the policy evidence behind an asset's moderation decision. To decide quickly, moderation skips questions whose answers could not change any action, so a report marked `moderation.explanationComplete: false` can credit a different rule, or show a different policy score, than a complete report would. Explaining answers those questions for the same content and returns the asset with `moderation.explanationComplete: true`; every action stays as decided. A decision made under policy settings that have since changed can't be explained as made: re-run it with `rerun: true` instead.

OpenAPI YAML
POST
https://api.calmlens.com/v1/assets/
/explain
const response = await client.assets.explain({
  "assetId": "asset_5Gm2Rk8XqT3wLp9VbN4c"
});

Request Body

Edit any value to update the generated request examples.

boolean (optional)
Moderate the asset again with the project's current policy, answering every question, instead of explaining the decision as made. Use it when the policy has changed since the decision (asset/policy-changed). Only uploaded images, text, and audio and video up to 50 MiB and 120 seconds can be moderated again. The request records asset.rerun-requested and returns the asset unchanged: it keeps its decision until the re-run's asset.classified and asset.<status> events report the new one, which can differ from the old one. If the re-run fails, the asset keeps its decision.

Response


Error Codes

401api-key/missing
Authentication required. Send your project API key in the X-Api-Key header.
401api-key/invalid
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403api-key/project-mismatch
This API key belongs to a different project. Use a key created for the project that owns this resource.
403auth/permission-denied
This API key lacks a permission the request needs (details.permission names it, such as assets:download for an asset's folder), or the resource belongs to another project.
400validation/invalid-request
The request's parameters, query or body are invalid. details.issues lists each problem, with its path and issue code.
415request/unsupported-content-type
Send the request body as application/json.
404asset/not-found
Asset not found
409asset/not-decided
This asset has no automatic moderation decision to explain yet.
409asset/policy-changed
The project's moderation policy has changed since this decision, so it can't be explained as made. Re-run moderation with the current policy instead.
409asset/reviewed
A reviewer has decided this asset, so its moderation can't be re-run.
409asset/not-retryable
Only assets that failed to process (status error) can be retried.
409asset/content-unavailable
This asset's content is no longer stored, so it can't be processed again. Upload it again instead.
423asset/held
The asset is held and this request can't change or deliver it. details.hold is `safety` for a safety hold or `copyright` for a copyright claim.
409asset/review-changed
The asset changed during review. Refresh and review the current decision.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Decide Asset

Record a reviewer's decision on an asset, replacing the policy's. The asset's `classification.moderation.status` becomes the decision, the matching `asset.<status>` event is sent with the request's `actor` (the API key, or the person an assistant's key acts for), and the decision and note are added to its review history. An asset still pending moderation can only be blocked or purged. Purging also needs `assets:delete` and permanently deletes the stored content.

OpenAPI YAML
POST
https://api.calmlens.com/v1/assets/
/decision
const response = await client.assets.decide({
  "decision": "blocked",
  "note": "Spam reported by three members",
  "assetId": "asset_5Gm2Rk8XqT3wLp9VbN4c"
});

Request Body

Edit any value to update the generated request examples.


Response


Error Codes

401api-key/missing
Authentication required. Send your project API key in the X-Api-Key header.
401api-key/invalid
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403api-key/project-mismatch
This API key belongs to a different project. Use a key created for the project that owns this resource.
403auth/permission-denied
This API key lacks a permission the request needs (details.permission names it, such as assets:download for an asset's folder), or the resource belongs to another project.
400validation/invalid-request
The request's parameters, query or body are invalid. details.issues lists each problem, with its path and issue code.
415request/unsupported-content-type
Send the request body as application/json.
404asset/not-found
Asset not found
409asset/processing
Wait for the asset to finish uploading and processing before deciding it.
409asset/decision-not-allowed
This asset has no moderation decision yet, so it can only be blocked or purged. Allow, limit or age-restrict it once moderation has decided it.
409asset/decision-unchanged
The asset already has this moderation status.
409asset/content-purged
This asset's content was purged, so it can only be blocked. Upload it again to have it moderated afresh.
409asset/review-changed
The asset changed during review. Refresh and review the current decision.
423asset/held
The asset is held and this request can't change or deliver it. details.hold is `safety` for a safety hold or `copyright` for a copyright claim.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Update Asset

Update an existing asset

OpenAPI YAML
PATCH
https://api.calmlens.com/v1/assets/
const response = await client.assets.update({
  "assetId": "asset_5Gm2Rk8XqT3wLp9VbN4c",
  "name": "Updated asset name",
  "visibility": "private"
});

Request Body

Edit any value to update the generated request examples.

string (optional)
Name of the asset
string (optional)
Optional description of the asset
string (optional)
External identifier for the asset
string (optional)
External URL associated with the asset (http or https)
tags[]string[]
Array of tags for the asset
Visibility (optional)
Visibility level of the asset
Allowed values
publicprivate

Response


Error Codes

401api-key/missing
Authentication required. Send your project API key in the X-Api-Key header.
401api-key/invalid
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403api-key/project-mismatch
This API key belongs to a different project. Use a key created for the project that owns this resource.
403auth/permission-denied
This API key lacks a permission the request needs (details.permission names it, such as assets:download for an asset's folder), or the resource belongs to another project.
400validation/invalid-request
The request's parameters, query or body are invalid. details.issues lists each problem, with its path and issue code.
415request/unsupported-content-type
Send the request body as application/json.
404asset/not-found
Asset not found
500asset/update-failed
Failed to update asset
409asset/duplicate-external-id
An asset with this externalId already exists in the project.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Move Asset

Move an asset into a folder, or to the project root

OpenAPI YAML
POST
https://api.calmlens.com/v1/assets/
/move
const response = await client.assets.move({
  "assetId": "asset_5Gm2Rk8XqT3wLp9VbN4c",
  "folderId": null
});

Request Body

Edit any value to update the generated request examples.

string (optional)

Response


Error Codes

401api-key/missing
Authentication required. Send your project API key in the X-Api-Key header.
401api-key/invalid
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403api-key/project-mismatch
This API key belongs to a different project. Use a key created for the project that owns this resource.
403auth/permission-denied
This API key lacks a permission the request needs (details.permission names it, such as assets:download for an asset's folder), or the resource belongs to another project.
400validation/invalid-request
The request's parameters, query or body are invalid. details.issues lists each problem, with its path and issue code.
415request/unsupported-content-type
Send the request body as application/json.
404asset/not-found
Asset not found
500asset/update-failed
Failed to update asset
423asset/held
The asset is held and this request can't change or deliver it. details.hold is `safety` for a safety hold or `copyright` for a copyright claim.
404folder/not-found
Folder not found
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Remove Asset Content

Remove stored content, including the content derived from it in child assets, while retaining the asset records

OpenAPI YAML
DELETE
https://api.calmlens.com/v1/assets/
/content
const response = await client.assets.removeContent({
  "assetId": "asset_5Gm2Rk8XqT3wLp9VbN4c"
});

Response


Error Codes

401api-key/missing
Authentication required. Send your project API key in the X-Api-Key header.
401api-key/invalid
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403api-key/project-mismatch
This API key belongs to a different project. Use a key created for the project that owns this resource.
403auth/permission-denied
This API key lacks a permission the request needs (details.permission names it, such as assets:download for an asset's folder), or the resource belongs to another project.
400validation/invalid-request
The request's parameters, query or body are invalid. details.issues lists each problem, with its path and issue code.
404asset/not-found
Asset not found
500asset/update-failed
Failed to update asset
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Delete Asset

Delete an uploaded asset, its child assets and their stored content from a project. Child assets (those with a `parentId`) are deleted only with the asset they were extracted from.

OpenAPI YAML
DELETE
https://api.calmlens.com/v1/assets/
const response = await client.assets.delete({
  "assetId": "asset_5Gm2Rk8XqT3wLp9VbN4c"
});

Error Codes

401api-key/missing
Authentication required. Send your project API key in the X-Api-Key header.
401api-key/invalid
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403api-key/project-mismatch
This API key belongs to a different project. Use a key created for the project that owns this resource.
403auth/permission-denied
This API key lacks a permission the request needs (details.permission names it, such as assets:download for an asset's folder), or the resource belongs to another project.
400validation/invalid-request
The request's parameters, query or body are invalid. details.issues lists each problem, with its path and issue code.
404asset/not-found
Asset not found
409asset/child-not-deletable
This asset was extracted from another asset (its `parentId`), so it can't be deleted on its own. Delete the asset it was extracted from instead, which deletes it too.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Run Asset Batch Operation

Delete up to 500 assets, or remove their stored content, in one request. Every asset must exist in the project, the API key needs `assets:delete` for its folder, and `delete` takes only uploaded assets, not child assets (those with a `parentId`); otherwise nothing is queued. The response gives the operation's `batchId` and confirms that it is queued. It then runs in the background: `delete` deletes each asset with its child assets and stored content and records `asset.deleted`, and `remove-content` removes the content as a removal would (reason `requested`) and records `asset.content-removed`; each of those events carries the `batch-id` fact. Assets under a safety hold, or in a folder the key can no longer delete from when the operation runs, are skipped and record no event. To follow the operation, read the events feed filtered by those types or by asset.

OpenAPI YAML
POST
https://api.calmlens.com/v1/projects/
/assets/batch
const response = await client.assets.batch({
  "assetIds": [
    "asset_5Gm2Rk8XqT3wLp9VbN4c"
  ],
  "operation": "remove-content"
});

Request Body

Edit any value to update the generated request examples.

assetIds[]string[]
IDs of 1 to 500 assets in the project.
OperationEnum
delete deletes each asset with its child assets and stored content. remove-content removes each asset's stored content and keeps the record, metadata and classification results.
Allowed values
deleteremove-content

Response

batchIdstring
ID of the batch operation. The asset.deleted and asset.content-removed events it records carry it as their batch-id fact.
statusliteral
queued: the operation runs in the background after the response.
assetCountnumber
Number of distinct assets the operation covers.

Error Codes

401api-key/missing
Authentication required. Send your project API key in the X-Api-Key header.
401api-key/invalid
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403api-key/project-mismatch
This API key belongs to a different project. Use a key created for the project that owns this resource.
403auth/permission-denied
This API key lacks a permission the request needs (details.permission names it, such as assets:download for an asset's folder), or the resource belongs to another project.
400validation/invalid-request
The request's parameters, query or body are invalid. details.issues lists each problem, with its path and issue code.
415request/unsupported-content-type
Send the request body as application/json.
404project/not-found
Project not found
404asset/not-found
Asset not found
409asset/child-not-deletable
This asset was extracted from another asset (its `parentId`), so it can't be deleted on its own. Delete the asset it was extracted from instead, which deletes it too.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

The asset object

Every endpoint that returns an asset returns this object. Its state is nested in three objects described in the asset lifecycle: upload, classification and content. classification.moderation follows the report format in Reading classification results. Child assets that CalmLens extracts during processing, such as images in a document, are assets too: their parentId is the asset they came from, and GET /assets/:assetId/children lists them.

The page object

List endpoints return a page of assets.

AssetPage
nextCursorstring (optional)
Pass as cursor for the next page; null when no more items remain
hasMoreboolean
Whether another page follows this one

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