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.

Every request names a project. Its API 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 policy/revision-conflict: retrieve it again and retry.

Guide: Moderation policies.

Endpoints

EndpointDescription
GET /projects/:projectId/policiesList the moderation policies of the project's organisation, and which one the project uses.
POST /projects/:projectId/policiesCreate a moderation policy in the project's organisation, from settings or as a copy of a built-in preset.
GET /projects/:projectId/policies/:policyIdGet one of the organisation's moderation policies by ID
PATCH /projects/:projectId/policies/:policyIdChange a policy's name, description or settings.
POST /projects/:projectId/policies/:policyId/presetReset a policy copied from a preset to its pinned preset version, or update an unchanged copy to the latest preset release
PUT /projects/:projectId/policies/:policyId/automatic-updatesSwitch automatic updates on or off for a project's preset policy.
DELETE /projects/:projectId/policies/:policyIdDelete a policy that no project or upload preset uses.
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.
automaticUpdatesboolean
Whether the policy follows its preset: it always has the latest preset settings until its first saved edit pins a copy
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 the moderation policies of the project's organisation, and which one the project uses. Policies are shared by the organisation's projects.

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

Response

projectPolicyIdstring
ID of the policy the project moderates with

Error Codes

401auth/missing-token
Authentication required. Send your project API key in the X-Api-Key header.
401auth/invalid-api-key
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403auth/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, such as assets:delete for an asset's folder, or the resource belongs to another project.
400validation/invalid-type
A field has the wrong type. details.issues lists each problem.
400validation/too-small
A value is below its minimum. details.issues lists each problem.
400validation/too-big
A value is above its maximum. details.issues lists each problem.
400validation/invalid-format
A string is not in the required format, such as an ID or URL. details.issues lists each problem.
400validation/invalid-value
A field has a value it cannot take. details.issues lists each problem.
400validation/unknown-field
The request has a field this endpoint does not accept.
404project/not-found
Project not found
500misc/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Create Policy

Create a moderation policy in the project'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/projects/
/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

401auth/missing-token
Authentication required. Send your project API key in the X-Api-Key header.
401auth/invalid-api-key
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403auth/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, such as assets:delete for an asset's folder, or the resource belongs to another project.
400validation/invalid-type
A field has the wrong type. details.issues lists each problem.
400validation/too-small
A value is below its minimum. details.issues lists each problem.
400validation/too-big
A value is above its maximum. details.issues lists each problem.
400validation/invalid-format
A string is not in the required format, such as an ID or URL. details.issues lists each problem.
400validation/invalid-value
A field has a value it cannot take. details.issues lists each problem.
400validation/unknown-field
The request has a field this endpoint does not accept.
415validation/unsupported-content-type
Send the request body as application/json.
404project/not-found
Project not found
500misc/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/projects/
/policies/
const response = await client.policies.retrieve({
  "policyId": "pol_2Wk7Rm4Xq9Lt3Vb8Np6C"
});

Response


Error Codes

401auth/missing-token
Authentication required. Send your project API key in the X-Api-Key header.
401auth/invalid-api-key
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403auth/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, such as assets:delete for an asset's folder, or the resource belongs to another project.
400validation/invalid-type
A field has the wrong type. details.issues lists each problem.
400validation/too-small
A value is below its minimum. details.issues lists each problem.
400validation/too-big
A value is above its maximum. details.issues lists each problem.
400validation/invalid-format
A string is not in the required format, such as an ID or URL. details.issues lists each problem.
400validation/invalid-value
A field has a value it cannot take. details.issues lists each problem.
400validation/unknown-field
The request has a field this endpoint does not accept.
404project/not-found
Project not found
404policy/not-found
Policy not found. Check the policy ID in the portal.
500misc/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 policy that follows automatic updates pins it as a copy under the same ID. Only policies that no other project uses or owns can be changed through a project's key.

OpenAPI YAML
PATCH
https://api.calmlens.com/v1/projects/
/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

401auth/missing-token
Authentication required. Send your project API key in the X-Api-Key header.
401auth/invalid-api-key
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403auth/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, such as assets:delete for an asset's folder, or the resource belongs to another project.
400validation/invalid-type
A field has the wrong type. details.issues lists each problem.
400validation/too-small
A value is below its minimum. details.issues lists each problem.
400validation/too-big
A value is above its maximum. details.issues lists each problem.
400validation/invalid-format
A string is not in the required format, such as an ID or URL. details.issues lists each problem.
400validation/invalid-value
A field has a value it cannot take. details.issues lists each problem.
400validation/unknown-field
The request has a field this endpoint does not accept.
415validation/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.
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 or owns this policy, so it can only be changed from the portal or that project.
500misc/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Reset or Update Policy Preset

Reset a policy copied from a preset to its pinned preset version, or update an unchanged copy to the latest preset release

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

Request Body

Edit any value to update the generated request examples.

OperationEnum
reset restores the settings of the pinned preset version, discarding edits; update moves an unchanged copy to the latest preset release
Allowed values
resetupdate
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

401auth/missing-token
Authentication required. Send your project API key in the X-Api-Key header.
401auth/invalid-api-key
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403auth/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, such as assets:delete for an asset's folder, or the resource belongs to another project.
400validation/invalid-type
A field has the wrong type. details.issues lists each problem.
400validation/too-small
A value is below its minimum. details.issues lists each problem.
400validation/too-big
A value is above its maximum. details.issues lists each problem.
400validation/invalid-format
A string is not in the required format, such as an ID or URL. details.issues lists each problem.
400validation/invalid-value
A field has a value it cannot take. details.issues lists each problem.
400validation/unknown-field
The request has a field this endpoint does not accept.
415validation/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.
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 or owns 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.
500misc/internal-error
An internal error occurred. Retry later, and quote requestId to support.

Set Policy Automatic Updates

Switch automatic updates on or off for a project's preset policy. A policy that follows automatic updates always has the latest preset settings.

OpenAPI YAML
PUT
https://api.calmlens.com/v1/projects/
/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

401auth/missing-token
Authentication required. Send your project API key in the X-Api-Key header.
401auth/invalid-api-key
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403auth/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, such as assets:delete for an asset's folder, or the resource belongs to another project.
400validation/invalid-type
A field has the wrong type. details.issues lists each problem.
400validation/too-small
A value is below its minimum. details.issues lists each problem.
400validation/too-big
A value is above its maximum. details.issues lists each problem.
400validation/invalid-format
A string is not in the required format, such as an ID or URL. details.issues lists each problem.
400validation/invalid-value
A field has a value it cannot take. details.issues lists each problem.
400validation/unknown-field
The request has a field this endpoint does not accept.
415validation/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.
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 or owns 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 a project's preset policy, and off for one that has them.
500misc/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 owns can be deleted through a project's key.

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

Error Codes

401auth/missing-token
Authentication required. Send your project API key in the X-Api-Key header.
401auth/invalid-api-key
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403auth/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, such as assets:delete for an asset's folder, or the resource belongs to another project.
400validation/invalid-type
A field has the wrong type. details.issues lists each problem.
400validation/too-small
A value is below its minimum. details.issues lists each problem.
400validation/too-big
A value is above its maximum. details.issues lists each problem.
400validation/invalid-format
A string is not in the required format, such as an ID or URL. details.issues lists each problem.
400validation/invalid-value
A field has a value it cannot take. details.issues lists each problem.
400validation/unknown-field
The request has a field this endpoint does not accept.
404project/not-found
Project not found
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 or owns this policy, so it can only be changed from the portal or that project.
500misc/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

401auth/missing-token
Authentication required. Send your project API key in the X-Api-Key header.
401auth/invalid-api-key
The API key is invalid, revoked or expired. Create a key under Developer → API Keys.
403auth/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, such as assets:delete for an asset's folder, or the resource belongs to another project.
400validation/invalid-type
A field has the wrong type. details.issues lists each problem.
400validation/too-small
A value is below its minimum. details.issues lists each problem.
400validation/too-big
A value is above its maximum. details.issues lists each problem.
400validation/invalid-format
A string is not in the required format, such as an ID or URL. details.issues lists each problem.
400validation/invalid-value
A field has a value it cannot take. details.issues lists each problem.
400validation/unknown-field
The request has a field this endpoint does not accept.
415validation/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.
500misc/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