Policies API reference

A moderation policy decides what happens to content in each category. Policies belong to your organisation and its projects share them. Each project moderates with one policy, and an upload preset can name another for the uploads it accepts.

Requests act through the API key's project: policy requests address the organisation's policies by ID, and GET /projects/:projectId/policy and PUT /projects/:projectId/policy read and choose the policy the project moderates with. The key needs policies:read to list and retrieve policies, and policies:write to create, change, delete and assign them. A key can change or delete only policies that no other project uses or owns, so it never changes how another project is moderated; change those in the portal.

Every change sends the policy's revision. A policy changed since you read it is refused with 409 policy/revision-conflict: retrieve it again and retry.

Guide: Moderation policies.

Endpoints

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

The policy object

Policy
idstring
Unique policy ID
namestring
Display name
descriptionstring
What the policy is for
revisionnumber
Changes with every saved change. Send it with each change; a policy changed since is refused with policy/revision-conflict.
projectIds[]string[]
Projects this policy moderates, as their default policy or through one of their upload presets
createdAtnumber
When the policy was created, in milliseconds since the Unix epoch
updatedAtnumber (optional)
When the policy was last changed, in milliseconds since the Unix epoch

Endpoint details

List Policies

List a page of the moderation policies of the API key's organisation, oldest first. Policies are shared by the organisation's projects; Get Project Policy says which one a project uses.

OpenAPI YAML
GET
https://api.calmlens.com/v1/policies
const response = await client.policies.list({
  "sort": "createdAt"
});

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.

Create Policy

Create a moderation policy in the API key's organisation, from settings or as a copy of a built-in preset. It moderates nothing until you assign it to a project or name it on an upload preset.

OpenAPI YAML
POST
https://api.calmlens.com/v1/policies
const response = await client.policies.create({
  "presetId": "children-platform",
  "name": "Kids section"
});

Request Body

Edit any value to update the generated request examples.

string (optional)
Display name. Required with settings; a copy of a preset defaults to its name.
string (optional)
What the policy is for
PresetIdEnum (optional)
Start from the latest release of a built-in preset instead: the copy keeps it as its reset baseline. Send this or settings.
Allowed values
general-communitychildren-platformeducation-supportwholesome-community

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.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Get Policy

Get one of the organisation's moderation policies by ID

OpenAPI YAML
GET
https://api.calmlens.com/v1/policies/
const response = await client.policies.retrieve({
  "policyId": "pol_2Wk7Rm4Xq9Lt3Vb8Np6C"
});

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.
404policy/not-found
Policy not found. Check the policy ID in the portal.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Update Policy

Change a policy's name, description or settings. Changes apply to later moderation. Saving a `live` policy pins it as a copy under the same ID. Only policies that no other project uses can be changed through a project's key.

OpenAPI YAML
PATCH
https://api.calmlens.com/v1/policies/
const response = await client.policies.update({
  "policyId": "pol_2Wk7Rm4Xq9Lt3Vb8Np6C",
  "revision": 1
});

Request Body

Edit any value to update the generated request examples.

number
The policy's current revision. A policy changed since is refused with policy/revision-conflict.
string (optional)
Display name
string (optional)
What the policy is for

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.
404policy/not-found
Policy not found. Check the policy ID in the portal.
409policy/revision-conflict
The policy changed. Retrieve it again and retry with its current revision.
409policy/projects-changed
The projects using this policy changed. Retrieve it again and review the affected projects before saving.
409policy/used-by-another-project
Another project uses this policy, so it can only be changed from the portal or that project.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Reset Policy

Restore the settings of the preset release a `pinned` or `copy` policy is pinned to, discarding its edits

OpenAPI YAML
POST
https://api.calmlens.com/v1/policies/
/reset
const response = await client.policies.reset({
  "policyId": "pol_2Wk7Rm4Xq9Lt3Vb8Np6C",
  "revision": 3,
  "presetVersion": 35
});

Request Body

Edit any value to update the generated request examples.

number
The policy's current revision. A policy changed since is refused with policy/revision-conflict.
number
The pinned preset release you reviewed: the policy's preset.version. A preset released since is refused with policy/preset-version-conflict.

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.
404policy/not-found
Policy not found. Check the policy ID in the portal.
409policy/revision-conflict
The policy changed. Retrieve it again and retry with its current revision.
409policy/projects-changed
The projects using this policy changed. Retrieve it again and review the affected projects before saving.
409policy/used-by-another-project
Another project uses this policy, so it can only be changed from the portal or that project.
400policy/no-preset
This policy has no preset baseline.
409policy/preset-version-conflict
The preset changed. Review the latest differences and retry with its version.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Upgrade Policy

Move a `pinned` or `copy` policy whose settings are unchanged from its preset release to the latest release of the preset

OpenAPI YAML
POST
https://api.calmlens.com/v1/policies/
/upgrade
const response = await client.policies.upgrade({
  "policyId": "pol_2Wk7Rm4Xq9Lt3Vb8Np6C",
  "revision": 3,
  "presetVersion": 36
});

Request Body

Edit any value to update the generated request examples.

number
The policy's current revision. A policy changed since is refused with policy/revision-conflict.
number
The preset release you reviewed: the policy's preset.latestVersion. A preset released since is refused with policy/preset-version-conflict.

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.
404policy/not-found
Policy not found. Check the policy ID in the portal.
409policy/revision-conflict
The policy changed. Retrieve it again and retry with its current revision.
409policy/projects-changed
The projects using this policy changed. Retrieve it again and review the affected projects before saving.
409policy/used-by-another-project
Another project uses this policy, so it can only be changed from the portal or that project.
400policy/no-preset
This policy has no preset baseline.
409policy/preset-version-conflict
The preset changed. Review the latest differences and retry with its version.
409policy/preset-update-unavailable
Only an unchanged copy of an older preset version can be updated. Reset or review your changes first.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Set Policy Automatic Updates

Switch automatic updates on or off for one of the organisation's own preset policies: on turns a `pinned` policy `live`, so it always has the latest preset settings, and off pins a `live` policy at its current preset release.

OpenAPI YAML
PUT
https://api.calmlens.com/v1/policies/
/automatic-updates
const response = await client.policies.setAutomaticUpdates({
  "policyId": "pol_2Wk7Rm4Xq9Lt3Vb8Np6C",
  "enabled": true,
  "revision": 3,
  "presetVersion": 35
});

Request Body

Edit any value to update the generated request examples.

boolean
true replaces the saved copy with a live reference to the latest preset under the same ID, discarding its changes; false pins the current preset version as a copy with unchanged settings
number
The policy's current revision. A policy changed since is refused with policy/revision-conflict.
number
The preset release you reviewed: the policy's preset.version to reset, its preset.latestVersion to update or switch automatic updates. A preset released since is refused with policy/preset-version-conflict.

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.
404policy/not-found
Policy not found. Check the policy ID in the portal.
409policy/revision-conflict
The policy changed. Retrieve it again and retry with its current revision.
409policy/projects-changed
The projects using this policy changed. Retrieve it again and review the affected projects before saving.
409policy/used-by-another-project
Another project uses this policy, so it can only be changed from the portal or that project.
409policy/preset-version-conflict
The preset changed. Review the latest differences and retry with its version.
409policy/automatic-updates-unavailable
Automatic updates can only be switched on for a saved copy of one of the organisation's own preset policies, and off for one that has them.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Delete Policy

Delete a policy that no project or upload preset uses. Only policies that no other project uses can be deleted through a project's key.

OpenAPI YAML
DELETE
https://api.calmlens.com/v1/policies/
const response = await client.policies.delete({
  "policyId": "pol_2Wk7Rm4Xq9Lt3Vb8Np6C"
});

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.
404policy/not-found
Policy not found. Check the policy ID in the portal.
409policy/in-use
Projects or upload presets still use this policy. Choose another policy for each of them before deleting it.
409policy/used-by-another-project
Another project uses this policy, so it can only be changed from the portal or that project.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Get Project Policy

Get the policy the project moderates with. Uploads through an upload preset that names its own policy use that one instead.

OpenAPI YAML
GET
https://api.calmlens.com/v1/projects/
/policy
const response = await client.policies.retrieveAssigned();

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.
404project/not-found
Project not found
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Assign Policy

Choose the policy the project moderates with. Later uploads use it, except those through an upload preset that names its own policy.

OpenAPI YAML
PUT
https://api.calmlens.com/v1/projects/
/policy
const response = await client.policies.assign({
  "policyId": "pol_2Wk7Rm4Xq9Lt3Vb8Np6C"
});

Request Body

Edit any value to update the generated request examples.

string
ID of one of the organisation's policies

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.
404project/not-found
Project not found
404policy/not-found
Policy not found. Check the policy ID in the portal.
500server/internal-error
An internal error occurred. Retry later, and quote requestId to support.

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