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.
client.assets.classify() selects wait=true, and client.assets.create() selects wait=false. Text and images support both flows. Documents, websites, audio, video and files over 20 MiB sent in parts always finish in the background and return with classification.moderation.decisionnull, even with wait=true. See Waiting for the decision for the complete flow.
Delete up to 500 assets, or remove their stored content, in one request.
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, a document's children list the pages they appear on in parentPages, and GET/assets/:assetId/children lists them.
The page object
List endpoints return a page of assets.
AssetPage
items[]*Asset[]
The items on this page
nextCursor*string (optional)
Pass as cursor for the next page; null when no more items remain
hasMore*boolean
Whether another page follows this one
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.
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, and details.role the least role that includes it), 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`).
422media/duration-limit
The audio or video is longer than allowed: details.durationSeconds is what its file states and details.limitSeconds the limit. Trim it or split it into separate uploads; before billing is set up, setting it up raises the limit.
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 (details.contentType and details.allowedContentTypes say what was sent and what it accepts).
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.
409payment/billing-required
Set up billing to upload websites.
429upload/rate-limit-reached
This organisation has started too many uploads in the last 10 seconds. Wait for the Retry-After period, or lower the pace of uploads.
402usage/uploads-paused
This upload would pass its organisation's usage limits, so it was refused. 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.
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.
400upload/options-in-query
Send the asset's name and fields in the request body (the JSON body, or the options part of a multipart/form-data upload), not in the query string.
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 as it is, without base64, with the `X-CalmLens-Upload: content` header. The body is `multipart/form-data` with two parts in this order: `options`, the asset's name and fields as a JSON object, then `file`, the file's bytes. Only transport values (`contentType`, `wait`, `sizeInBytes` and the multipart values) go in the query string; asset fields there are refused with `upload/options-in-query`, so customer content never appears in logged URLs. This is the upload path the SDKs use for files. Send an `Idempotency-Key` header to retry safely without creating a second asset.
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, and details.role the least role that includes it), 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`).
422media/duration-limit
The audio or video is longer than allowed: details.durationSeconds is what its file states and details.limitSeconds the limit. Trim it or split it into separate uploads; before billing is set up, setting it up raises the limit.
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 (details.contentType and details.allowedContentTypes say what was sent and what it accepts).
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.
429upload/rate-limit-reached
This organisation has started too many uploads in the last 10 seconds. Wait for the Retry-After period, or lower the pace of uploads.
402usage/uploads-paused
This upload would pass its organisation's usage limits, so it was refused. 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.
400upload/options-in-query
Send the asset's name and fields in the request body (the JSON body, or the options part of a multipart/form-data upload), not in the query string.
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 sending the first part with the `X-CalmLens-Upload: part` header. The body is `multipart/form-data` with two parts in this order: `options`, the asset's name and fields as a JSON object, then `file`, the file's bytes. Only transport values (`contentType`, `wait`, `sizeInBytes` and the multipart values) go in the query string; asset fields there are refused with `upload/options-in-query`, so customer content never appears in logged URLs. 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.
import { readFile } from"node:fs/promises";
// The asset's fields go in the options part, then the file: never in the URL.const form =newFormData();
form.append("options", JSON.stringify({"name":"large-video.mp4"}));
form.append(
"file",
newBlob([awaitreadFile("large-video.part1")], { type: "video/mp4" }),
"large-video.part1",
);
const response =awaitfetch("https://api.calmlens.com/v1/projects/proj_8fK2mQx7Lp4NvB3tRz9Y/assets?contentType=video%2Fmp4&partNumber=1&isFinal=false", {
method: "POST",
headers: {
"X-Api-Key": "your-api-key",
"X-CalmLens-Upload": "part",
},
body: form,
});
if (!response.ok) thrownewError(`HTTP ${response.status}`);
const data =await response.json();
Response
Asset
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, and details.role the least role that includes it), 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`).
422media/duration-limit
The audio or video is longer than allowed: details.durationSeconds is what its file states and details.limitSeconds the limit. Trim it or split it into separate uploads; before billing is set up, setting it up raises the limit.
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 (details.contentType and details.allowedContentTypes say what was sent and what it accepts).
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.
429upload/rate-limit-reached
This organisation has started too many uploads in the last 10 seconds. Wait for the Retry-After period, or lower the pace of uploads.
402usage/uploads-paused
This upload would pass its organisation's usage limits, so it was refused. 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.
400upload/options-in-query
Send the asset's name and fields in the request body (the JSON body, or the options part of a multipart/form-data upload), not in the query string.
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.
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, and details.role the least role that includes it), 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`).
422media/duration-limit
The audio or video is longer than allowed: details.durationSeconds is what its file states and details.limitSeconds the limit. Trim it or split it into separate uploads; before billing is set up, setting it up raises the limit.
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 (details.contentType and details.allowedContentTypes say what was sent and what it accepts).
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.
409payment/billing-required
Set up billing to upload websites.
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, size limit, moderation policy and processing options, such as OCR and person and face detection. 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.
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 (details.contentType and details.allowedContentTypes say what was sent and what it accepts).
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`).
422media/duration-limit
The audio or video is longer than allowed: details.durationSeconds is what its file states and details.limitSeconds the limit. Trim it or split it into separate uploads; before billing is set up, setting it up raises the limit.
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.
409payment/billing-required
Set up billing to upload websites.
429upload/rate-limit-reached
This organisation has started too many uploads in the last 10 seconds. Wait for the Retry-After period, or lower the pace of uploads.
402usage/uploads-paused
This upload would pass its organisation's usage limits, so it was refused. See details.reason; an owner can review them in Billing.
400upload-payload/invalid
Upload payload is invalid.
400upload/options-in-query
Send the asset's name and fields in the request body (the JSON body, or the options part of a multipart/form-data upload), not in the query string.
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 as it is, without base64, with the `X-CalmLens-Upload: content` header. The body is `multipart/form-data` with two parts in this order: `options`, the asset's name and fields as a JSON object, then `file`, the file's bytes. Only transport values (`contentType`, `wait`, `sizeInBytes` and the multipart values) go in the query string; asset fields there are refused with `upload/options-in-query`, so customer content never appears in logged URLs. The options hold only the file's `name` and optional `description`. 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.
import { readFile } from"node:fs/promises";
// The asset's fields go in the options part, then the file: never in the URL.const form =newFormData();
form.append("options", JSON.stringify({"name":"photo.jpg"}));
form.append(
"file",
newBlob([awaitreadFile("photo.jpg")], { type: "image/jpeg" }),
"photo.jpg",
);
const response =awaitfetch("https://api.calmlens.com/v1/upload-presets/preset_4Lk8Qw2Xm9Rt5Vb3Nc7P/assets?contentType=image%2Fjpeg&wait=false", {
method: "POST",
headers: {
"Authorization": "Bearer your-upload-token",
"X-CalmLens-Upload": "content",
},
body: form,
});
if (!response.ok) thrownewError(`HTTP ${response.status}`);
const data =await response.json();
Response
UploadedAsset
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 (details.contentType and details.allowedContentTypes say what was sent and what it accepts).
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`).
422media/duration-limit
The audio or video is longer than allowed: details.durationSeconds is what its file states and details.limitSeconds the limit. Trim it or split it into separate uploads; before billing is set up, setting it up raises the limit.
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.
409payment/billing-required
Set up billing to upload websites.
429upload/rate-limit-reached
This organisation has started too many uploads in the last 10 seconds. Wait for the Retry-After period, or lower the pace of uploads.
402usage/uploads-paused
This upload would pass its organisation's usage limits, so it was refused. See details.reason; an owner can review them in Billing.
400upload-payload/invalid
Upload payload is invalid.
400upload/options-in-query
Send the asset's name and fields in the request body (the JSON body, or the options part of a multipart/form-data upload), not in the query string.
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.
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
422media/duration-limit
The audio or video is longer than allowed: details.durationSeconds is what its file states and details.limitSeconds the limit. Trim it or split it into separate uploads; before billing is set up, setting it up raises the limit.
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 (details.contentType and details.allowedContentTypes say what was sent and what it accepts).
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.
409payment/billing-required
Set up billing to upload websites.
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.
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, and details.role the least role that includes it), 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.
const response =await client.assets.search({
"query": "a red car at night",
"mode": "hybrid",
"pageSize": 10});
Response
query*string
items[]*object[]
semanticStatus*SemanticStatusEnum
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, and details.role the least role that includes it), 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.
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, and details.role the least role that includes it), 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 by external ID
Get the project's asset that has this `externalId`, such as the one an `asset/duplicate-external-id` error refers to
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, and details.role the least role that includes it), 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.
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, and details.role the least role that includes it), 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
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, and details.role the least role that includes it), 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.
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, and details.role the least role that includes it), 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.
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.decision` 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.
const response =await client.assets.decide({
"decision": "blocked",
"note": "Spam reported by three members",
"assetId": "asset_e5Gm2Rk8XqT3wLp9VbN4"});
Response
Asset
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, and details.role the least role that includes it), 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.
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.
Request Asset Review
Send an asset to the project's human review queue, such as when one of your app's users reports it. A report doesn't change how the asset is delivered: a reviewer's decision does, as for a sampled review, and is sent as `asset.review-completed` and, when it changes the asset's status, the matching `asset.<status>` event. A new review answers 201 and sends `asset.review-requested` with the `review-reason` `reported`, the note and the request's `actor` (the API key, or the person an assistant's key acts for). While the asset is already waiting for a review, the request answers 200 with that review and changes nothing.
const response =await client.assets.requestReview({
"note": "Reported by a member as harassment",
"assetId": "asset_e5Gm2Rk8XqT3wLp9VbN4"});
Response
AssetReviewRequest
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, and details.role the least role that includes it), 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-reviewable
The human review queue can't take this asset. details.reason is `child-asset` for content extracted from another asset (report the uploaded asset instead), `not-moderated` while it has no moderation decision yet, or `content-unavailable` when its content is no longer stored.
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.
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.
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, and details.role the least role that includes it), 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
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, and details.role the least role that includes it), 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
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, and details.role the least role that includes it), 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.
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, and details.role the least role that includes it), 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.
ID of the batch operation. The asset.deleted and asset.content-removed events it records carry it as their batch-id fact.
status*literal
queued: the operation runs in the background after the response.
assetCount*number
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, and details.role the least role that includes it), 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.
Last updated
Signing in
Deleting account
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